<?php
namespace app\admin\controller;

use think\Controller;
//bet可以定死
//但是colums一定要get上来
class Single extends controller
{
    //方法
     public function id(){
        switch (session('usertype')) {
            case 1:
            $u1 = session('adminid');
            $u2 = model('user')->findtopuser1(session('adminid'));
            foreach($u2 as $k1 => $res2k){
                $u3 = model('user')->findtopuser1($res2k);
            }
            foreach($u3 as $k2 => $res3k){
                $u4 = model('user')->findtopuser1($res3k);
            }
            foreach($u4 as $k3 => $res4k){
                $u5 = model('user')->findtopuser1($res4k);
            }
            foreach($u5 as $k4 => $res5k){
                $u6 = model('user')->findtopuser1($res5k);
            }
            foreach($u6 as $k5 => $res6k){
                $u7 = model('user')->findtopuser1($res6k);
            }
            $result["u1"]=$u1;
            $result["u2"]=$u2;
            $result["u3"]=$u3;
            $result["u4"]=$u4;
            $result["u5"]=$u5;
            $result["u6"]=$u6;
            $result["u7"]=$u7;
            return $result;
            break;
            
            case 2:
            $u2 = session('adminid');
            // $u2 = model('user')->findtopuser1(session('adminid'));
            $u3 = model('user')->findtopuser1(session('adminid'));
            foreach($u3 as $k2 => $res3k){
                $u4 = model('user')->findtopuser1($res3k);
            }
            foreach($u4 as $k3 => $res4k){
                $u5 = model('user')->findtopuser1($res4k);
            }
            foreach($u5 as $k4 => $res5k){
                $u6 = model('user')->findtopuser1($res5k);
            }
            foreach($u6 as $k5 => $res6k){
                $u7 = model('user')->findtopuser1($res6k);
            }     
            $result["u2"]=$u2;
            $result["u3"]=$u3;
            $result["u4"]=$u4;
            $result["u5"]=$u5;
            $result["u6"]=$u6;
            $result["u7"]=$u7;
            return $result;
            break;

            case 3:
            $u3 = session('adminid');
            $u4 = model('user')->findtopuser1(session('adminid'));
            foreach($u4 as $k3 => $res4k){
                $u5 = model('user')->findtopuser1($res4k);
            }
            foreach($u5 as $k4 => $res5k){
                $u6 = model('user')->findtopuser1($res5k);
            }
            foreach($u6 as $k5 => $res6k){
                $u7 = model('user')->findtopuser1($res6k);
            }
            $result["u3"]=$u3;
            $result["u4"]=$u4;
            $result["u5"]=$u5;
            $result["u6"]=$u6;
            $result["u7"]=$u7;     
            // mp($result);
            return $result;
            break;

            case 4:
            $u4 = session('adminid');
            $u5 = model('user')->findtopuser1(session('adminid'));
            foreach($u5 as $k4 => $res5k){
                $u6 = model('user')->findtopuser1($res5k);
            }
            foreach($u6 as $k5 => $res6k){
                $u7 = model('user')->findtopuser1($res6k);
            }     
            $result["u4"]=$u4;
            $result["u5"]=$u5;
            $result["u6"]=$u6;
            $result["u7"]=$u7;
            return $result;
            break;

            case 5:
            $u5 = session('adminid');
                $u6 = model('user')->findtopuser1(session('adminid'));
            foreach($u6 as $k5 => $res6k){
                $u7 = model('user')->findtopuser($res6k);
            }     
            $result["u5"]=$u5;
            $result["u6"]=$u6;
            $result["u7"]=$u7;
            return $result;
            break;

            case 6:
                $u6= session('adminid');
                $u7 = model('user')->findtopuser1(session('adminid'));
                $result["u6"]=$u6;
                $result["u7"]=$u7;
                return $result;
                break;

            default:
            $u7 = session('adminid');     
            $result["u7"]= $u7;
            return $result;
            break;
        }
    }
    //id链
    public function id2(){
        switch (session('usertype')) {
            case 1:
            $res2 = model('user')->findtopuser1(session('adminid'));
            // mp($res2);
            foreach($res2 as $k1 => $res2k){
                $res3 = model('user')->findtopuser1($res2k);
            }
            foreach($res3 as $k2 => $res3k){
                $res4 = model('user')->findtopuser1($res3k);
            }
            foreach($res4 as $k3 => $res4k){
                $res5 = model('user')->findtopuser1($res4k);
            }
            foreach($res5 as $k4 => $res5k){
                $res6 = model('user')->findtopuser1($res5k);
            }
            foreach($res6 as $k5 => $res6k){
                $res7 = model('user')->findtopuser1($res6k);
            }     
            $res = array_merge($res2,$res3,$res4,$res5,$res6,$res7);
            
            return $res;
            break;
            
            case 2:
            $res2[] = session('adminid');
            foreach($res2 as $k1 => $res2k){
                $res3 = model('user')->findtopuser1($res2k);
            }
            foreach($res3 as $k2 => $res3k){
                $res4 = model('user')->findtopuser1($res3k);
            }
            foreach($res4 as $k3 => $res4k){
                $res5 = model('user')->findtopuser1($res4k);
            }
            foreach($res5 as $k4 => $res5k){
                $res6 = model('user')->findtopuser1($res5k);
            }
            foreach($res6 as $k5 => $res6k){
                $res7 = model('user')->findtopuser1($res6k);
            }     
            $res = array_merge($res2,$res3,$res4,$res5,$res6,$res7);
            // mp($res);
            return $res;

                break;
            case 3:
            $res3[] = session('adminid');
            foreach($res3 as $k2 => $res3k){
                $res4 = model('user')->findtopuser1($res3k);
            }
            foreach($res4 as $k3 => $res4k){
                $res5 = model('user')->findtopuser1($res4k);
            }
            foreach($res5 as $k4 => $res5k){
                $res6 = model('user')->findtopuser1($res5k);
            }
            foreach($res6 as $k5 => $res6k){
                $res7 = model('user')->findtopuser1($res6k);
            }     
            $res = array_merge($res3,$res4,$res5,$res6,$res7);
            // mp($res);
            return $res;

                break;
                case 4:
                $res4[] = session('adminid');
                foreach($res4 as $k3 => $res4k){
                    $res5 = model('user')->findtopuser1($res4k);
                }
                foreach($res5 as $k4 => $res5k){
                    $res6 = model('user')->findtopuser1($res5k);
                }
                foreach($res6 as $k5 => $res6k){
                    $res7 = model('user')->findtopuser1($res6k);
                }     
                $res = array_merge($res4,$res5,$res6,$res7);
                // mp($res);
                return $res;

                    break;
                    case 5:
                    $res5[] = session('adminid');
                    foreach($res5 as $k4 => $res5k){
                        $res6 = model('user')->findtopuser1($res5k);
                    }
                    foreach($res6 as $k5 => $res6k){
                        $res7 = model('user')->findtopuser1($res6k);
                    }     
                    $res = array_merge($res5,$res6,$res7);
                    // mp($res);
                    return $res;

                        break;
                        case 6:
                        $res6[] = session('adminid');
                        foreach($res6 as $k5 => $res6k){
                            $res7 = model('user')->findtopuser1($res6k);
                        }     
                        $res = array_merge($res6,$res7);
                        // mp($res);
                        return $res;

                            break;
            default:
            $res7[] = session('adminid');     
            $res = array_merge($res7);
            // mp($res);
            return $res;

                break;
        }
        
        return $this->fetch();
    }
    //找当前期数
    public function dangqianqishu(){
        $stime=time();
        $datatime = 0;
        $opent = model('openplate')->findall();
        foreach($opent as $key => $o){
            if($stime >= $o['opentime'] && $stime <= $o['tclosetime']){
                $datatime = $o['datetime'];
            }
        }
        return $datatime;
    }
    //根据盘口，bet，colums，id链，期数找注单
    public function quanbuzhudan($panlei,$bet,$colums,$item,$datatime){
        $uid = $this->id();//
        foreach($uid['u7'] as $key => $items){
            $res1 = model('ordered')->findjishizonge($panlei,$bet,$colums,$items,$datatime);//
            $res[] = $res1;
        }
        return $res;
    }
    //拿占成成数
    public function zhaoupoccupy(){
        $uid = $this->id();//id链
        foreach($uid['u7'] as $key => $items){
            $upoccupyf[] = model('occupy')->finduid2($items);//根据id找成数
            foreach($upoccupyf as $key => $items1){
                foreach ($items1 as $key1 => $items){
                    switch(session('usertype')){
                        case 1:
                            $upoccupy1[$items['user_id']] = $items['houtai'];
                        break;
                        case 2:
                            $upoccupy1[$items['user_id']] = $items['zongjian'];
                        break;
                        case 3:
                            $upoccupy1[$items['user_id']] = $items['dagudong'];
                        break;
                        case 4:
                            $upoccupy1[$items['user_id']] = $items['gudong'];
                        break;
                        case 5:
                            $upoccupy1[$items['user_id']] = $items['zongdai'];
                        break;
                        case 6:
                            $upoccupy1[$items['user_id']] = $items['daili'];
                        break;
                    }
                }
            }
            $upoccupy[$items['user_id']] = $upoccupy1[$items['user_id']]/100;
        }
        // mp($upoccupy);
        return $upoccupy;
    }
    //计算总金额
    public function zongjine($res){
        for($i=0;$i<sizeof($res);$i++){
            foreach ($res[$i] as $key => $v) {
                $zongjine+=$v['price'];
            }
        }//总金额
        return $zongjine;
    }
    //拿下级补货注单
    public function betzhudan($res){
        for($i=0;$i<sizeof($res);$i++){
            foreach ($res[$i] as $key => $v) {
                $bets = $v['bets'];
                $new[$bets][] = $v;
            }
        }//特码的1-49号球的注单以及特码三双大小那些
        return $new;
    }
    //拿总笔数
    public function zongbishu($bishu2){
        foreach($bishu2 as $bishu => $i){

            $zongbishu += 1;
        }
        return $zongbishu;
    }    
    //拿补货
    public function buhuoc0($new){
        foreach($new as $key=>$item){
            foreach($item as $key2=>$item2){
                $bets2 = $item2['bets'];
                $buhuo[$bets2] = $item2['zijibuhuo'];//补货
            }
        }
        return $buhuo;        
    }//不变 
    //拿笔数
    public function bishuc0($new){
        foreach($new as $key=>$item){
            $bishu[]=count($item);//特码的注单笔数
        }
        // mp($bishu);
        return $bishu;              
    }//不变

    //当注单不存在的时候跳转新的空页面(精简)
    public function banbo(){
        $arr = model('orders')->findcount();
                foreach ($arr as $key11 => $item11) {
                    $zongarr += $item11;
                }
        $resultzhengxiao = model("rate")->findszhengxiao();//正肖赔率
        $resultyixiao = model("rate")->findsyixiao();//一肖赔率
        $resultsanzhongyi = model("rate")->findsanzhongyi();//三中一赔率
        $resultwbzhong = model("rate")->findswbzhong();//不中
        $resultSQZRate = model("rate")->findsSQZRate();//三全中赔率
        $res10 = model("rate")->finds(10);//10连肖
        $resweishulianRate = model("rate")->findsweishulianRate();//连肖赔率
        $resultZTDXXduoxiaoRate = model("rate")->findsZTDXXduoxiaoRate();//正特多选项
        $resultTemaSXTWRate = model("rate")->findsTemaSXTWRate();//特码生肖头尾赔率
        $resultBanBoRate = model("rate")->findsBanBoRate();//半波赔率
        $resultsevenRate = model("rate")->findssevenRate();//七码赔率
        $resultZm1to6Rate = model("rate")->findsZm1to6Rate();//正码一到六赔率
        $resultZhengmaTeRate = model("rate")->findsZhengmaTeRate();//正码特赔率
        $resultZhengmaRate = model("rate")->findsZhengmaRate();//正码赔率
        $resultTema = model("rate")->findTemaRate();//特码赔率
        // //mp1($resultTema[0]['ra']);
        $resultZMGGRate = model("rate")->findsZMGGRate();//正码过关赔率
        $resultBanBoRate = model("rate")->findsBanBoRate();//半波赔率
        $resultsevenRate = model("rate")->findssevenRate();//七码赔率
        $announce = model('announce')->findstatus(2); 
        $this->assign('announce',$announce);//广告
        $this->assign('resultBanBoRate', $resultBanBoRate);//赔率
        $this->assign('resultsevenRate', $resultsevenRate);//赔率
        $this->assign('BanBoRate',$resultBanBoRate);
        $this->assign('sevenRate',$resultsevenRate);
        $this->assign('resultTema', $resultTema);
        $this->assign('resZhengma', $resultZhengmaRate);
        $this->assign('resZhengmaTeRate', $resultZhengmaTeRate);
        $this->assign('resultZm1to6Rate', $resultZm1to6Rate);
        $this->assign('resultTemaSXTWRate', $resultTemaSXTWRate);
        $this->assign('resultZTDXXduoxiaoRate', $resultZTDXXduoxiaoRate);
        $this->assign('resweishulianRate', $resweishulianRate);
        $this->assign('res10', $res10);
        $this->assign('resultZMGGRate',$resultZMGGRate);
        $this->assign('resultSQZRate',$resultSQZRate);
        $this->assign('resultwbzhong',$resultwbzhong);
        $this->assign('resultsanzhongyi',$resultsanzhongyi);
        $this->assign('resultyixiao',$resultyixiao);
        $this->assign('resultzhengxiao',$resultzhengxiao);
                            $this->assign('arr',$arr);
        $this->assign('zongarr',$zongarr);
        return $this->fetch(); 
    }
    //当注单不存在的时候跳转新的空页面(精简)
    public function inject(){
        $arr = model('orders')->findcount();
                foreach ($arr as $key11 => $item11) {
                    $zongarr += $item11;
                }
        $resultTema = model("rate")->findTemaRate();//特码赔率
        $announce = model('announce')->findstatus(2); 
        $this->assign('announce',$announce);//广告
        $this->assign('resultTema', $resultTema);//赔率
                            $this->assign('arr',$arr);
        $this->assign('zongarr',$zongarr);
        return $this->fetch(); 
    }
    //当注单不存在的时候跳转新的空页面(精简)
    public function inject1to6(){
        $arr = model('orders')->findcount();
                foreach ($arr as $key11 => $item11) {
                    $zongarr += $item11;
                }
        $resultZm1to6Rate = model("rate")->findsZm1to6Rate();//正码一到六赔率
        $announce = model('announce')->findstatus(2); 
        $this->assign('announce',$announce);//广告
        $this->assign('resultZm1to6Rate', $resultZm1to6Rate);//赔率
                            $this->assign('arr',$arr);
        $this->assign('zongarr',$zongarr);
        return $this->fetch(); 
    }
    //当注单不存在的时候跳转新的空页面
    public function injectdxx(){
        $arr = model('orders')->findcount();
                foreach ($arr as $key11 => $item11) {
                    $zongarr += $item11;
                }
        $res10 = model("rate")->finds(10);//10连肖 要
        $resweishulianRate = model("rate")->findsweishulianRate();//连肖赔率 要
        $resultZTDXXduoxiaoRate = model("rate")->findsZTDXXduoxiaoRate();//正特多选项 要
        $resultZMGGRate = model("rate")->findsZMGGRate();//正码过关赔率 要
        $announce = model('announce')->findstatus(2); 
        $this->assign('announce',$announce);//广告
        $this->assign('resultZTDXXduoxiaoRate', $resultZTDXXduoxiaoRate);
        $this->assign('resweishulianRate', $resweishulianRate);
        $this->assign('res10', $res10);
        $this->assign('resultZMGGRate',$resultZMGGRate); 
        $this->assign('arr',$arr);
        $this->assign('zongarr',$zongarr);
        return $this->fetch(); 
    }
    //当注单不存在的时候跳转新的空页面
    public function injectlianma(){
        $arr = model('orders')->findcount();
                foreach ($arr as $key11 => $item11) {
                    $zongarr += $item11;
                }
        $resultSQZRate = model("rate")->findsSQZRate();//三全中赔率
        $announce = model('announce')->findstatus(2); 
        $this->assign('announce',$announce);//广告
        $this->assign('resultSQZRate',$resultSQZRate);//连码赔率
                            $this->assign('arr',$arr);
        $this->assign('zongarr',$zongarr);
        return $this->fetch(); 
    }
    //当注单不存在的时候跳转新的空页面
    public function injectmiss(){
        $arr = model('orders')->findcount();
                foreach ($arr as $key11 => $item11) {
                    $zongarr += $item11;
                }
        $resultwbzhong = model("rate")->findswbzhong();//不中 要
        $resultsanzhongyi = model("rate")->finds(15);//多中配率 要        
        $announce = model('announce')->findstatus(2); 
        $this->assign('announce',$announce);//广告
        $this->assign('resultwbzhong',$resultwbzhong);
        $this->assign('resultsanzhongyi',$resultsanzhongyi);
                            $this->assign('arr',$arr);
        $this->assign('zongarr',$zongarr);
        return $this->fetch(); 
    }
    //当注单不存在的时候跳转新的空页面
    public function injectqise(){
        $arr = model('orders')->findcount();
                foreach ($arr as $key11 => $item11) {
                    $zongarr += $item11;
                }
        $resultzhengxiao = model("rate")->finds(9); //正肖赔率
        $resultyixiao = model("rate")->finds(13); //一肖赔率
        $announce = model('announce')->findstatus(2); 
        $this->assign('announce',$announce);//广告
        $this->assign('resultyixiao',$resultyixiao);
        $this->assign('resultzhengxiao',$resultzhengxiao);
                            $this->assign('arr',$arr);
        $this->assign('zongarr',$zongarr);
        return $this->fetch(); 
    }
    //当注单不存在的时候跳转新的空页面
    public function injecttws(){
        $arr = model('orders')->findcount();
                foreach ($arr as $key11 => $item11) {
                    $zongarr += $item11;
                }
        $resultTemaSXTWRate = model("rate")->findsTemaSXTWRate();//特码生肖头尾赔率    
        $announce = model('announce')->findstatus(2); 
        $this->assign('announce',$announce);//广告
        $this->assign('resultTemaSXTWRate', $resultTemaSXTWRate);
                            $this->assign('arr',$arr);
        $this->assign('zongarr',$zongarr);
        return $this->fetch(); 
    }
    //当注单不存在的时候跳转新的空页面
    public function injectzheng(){
        $arr = model('orders')->findcount();
                foreach ($arr as $key11 => $item11) {
                    $zongarr += $item11;
                }
        $resZhengma = model("rate")->findsZhengmaRate();//正码赔率      
        $resultTema = model("rate")->findTemaRate();//特码赔率
        $announce = model('announce')->findstatus(2); 
        $this->assign('announce',$announce);//广告
        $this->assign('resZhengma', $resZhengma);//赔率
        $this->assign('resultTema', $resultTema);//赔率
                            $this->assign('arr',$arr);
        $this->assign('zongarr',$zongarr);
        return $this->fetch(); 
    }
    //当注单不存在的时候跳转新的空页面
    public function injectzmte(){
        $arr = model('orders')->findcount();
                foreach ($arr as $key11 => $item11) {
                    $zongarr += $item11;
                }
        $resultZhengmaTeRate = model("rate")->findsZhengmaTeRate();//正码特赔率
        $announce = model('announce')->findstatus(2); 
        $this->assign('announce',$announce);//广告
        $this->assign('resZhengmaTeRate', $resultZhengmaTeRate);
                            $this->assign('arr',$arr);
        $this->assign('zongarr',$zongarr);
        return $this->fetch(); 
    }

    //全部
    public function jinec0($new){
        foreach($new as $key=>$item){
            foreach($item as $key2=>$item2){
                $bets2 = $item2['bets'];
                $jine[$bets2] += $item2['price'];//金额
            }
        }
        return $jine;
    }//金额变
    public function yingkuic0($new,$zongjine){
        foreach($new as $key=>$item){
            foreach($item as $key2=>$item2){
                $bets2 = $item2['bets'];
                $jine[$bets2] += $item2['price'];//金额
                $yingkui[$bets2] = $zongjine-$jine[$bets2]*$item2['rate'];//预计盈亏
            }
        }
        return $yingkui;         
    }//盈亏变


    //实货
    public function jinec1($new,$upoccupy){
        $keys = array_keys($upoccupy);
        // mp($keys); 
        foreach($new as $key=>$item){
            foreach($item as $key2=>$item2){
                for($i=0;$i<sizeof($keys);$i++){
                    if($item2['user_id']==$keys[$i]){
                        $upoccupy = $upoccupy[$keys[$i]];
                    }
                }
                $bets2 = $item2['bets'];
                $jine[$bets2] += (($item2['price'])*$upoccupy)-$buhuo[$bets2];//实货
            }
        }
        // mp($jine);          
        return $jine;
    }//金额变
    public function yingkuic1($new,$zongjine,$upoccupy){
        $keys = array_keys($upoccupy);
        foreach($new as $key=>$item){
            foreach($item as $key2=>$item2){
                for($i=0;$i<sizeof($keys);$i++){
                    if($item2['user_id']==$keys[$i]){
                        $upoccupy = $upoccupy[$keys[$i]];
                    }
                }
                $bets2 = $item2['bets'];
                $jine[$bets2] += (($item2['price'])*$upoccupy)-$buhuo[$bets2];//实货
                $yingkui[$bets2] = $zongjine-$jine[$bets2]*$item2['rate'];//预计盈亏
            }
        }
        return $yingkui;
    }//盈亏变

    //成数
    public function jinec2($new,$upoccupy){
        $keys = array_keys($upoccupy);
        foreach($new as $key=>$item){
            foreach($item as $key2=>$item2){
                for($i=0;$i<sizeof($keys);$i++){
                    if($item2['user_id']==$keys[$i]){
                        $upoccupy = $upoccupy[$keys[$i]];
                    }
                }
                $bets2 = $item2['bets'];
                $jine[$bets2] += ($item2['price'])*$upoccupy;//成数，金额的占成
            }
        }
        return $jine;
    }//金额变
    public function yingkuic2($new,$zongjine,$upoccupy){
        $keys = array_keys($upoccupy);
        foreach($new as $key=>$item){
            foreach($item as $key2=>$item2){
                for($i=0;$i<sizeof($keys);$i++){
                    if($item2['user_id']==$keys[$i]){
                        $upoccupy = $upoccupy[$keys[$i]];
                    }
                }
                $bets2 = $item2['bets'];
                $jine[$bets2] += ($item2['price'])*$upoccupy;//成数，金额的占成
                $yingkui[$bets2] = $zongjine-$jine[$bets2]*$item2['rate'];//预计盈亏
            }
        }
        return $yingkui;
    }//盈亏变

    //收补 金额就是下级补货
    public function jinec3($new){
        foreach($new as $key=>$item){
            foreach($item as $key2=>$item2){
                $bets2 = $item2['bets'];
                $jine[$bets2] = $item2['price']; 
            }
        }
        return $jine;
    }//金额变
    public function xiajibuhuo($new){
        foreach($new as $key=>$item){
            foreach($item as $key2=>$item2){
                $bets2 = $item2['bets'];
                $xiajibuhuo[$bets2] = $item2['price'];//补货
            }
        }
        return $xiajibuhuo;        
    }//下级补货
    public function yingkuic3($new,$zongjine){
        foreach($new as $key=>$item){
            foreach($item as $key2=>$item2){
                $bets2 = $item2['bets']; 
                $jine[$bets2] = $item2['price']; 
                $yingkui[$bets2] = $zongjine-$jine[$bets2]*$item2['rate'];//预计盈亏                 
            }
        }
        return $yingkui;
    }//盈亏变  

    //补货，自己补货出去 这里补货就是金额
    public function jinec4($new){
        foreach($new as $key=>$item){
            foreach($item as $key2=>$item2){
                $bets2 = $item2['bets'];
                $jine[$bets2] = $item2['zijibuhuo'];
            }
        }
        return $jine;
    }//金额变
    public function yingkuic4($new,$zongjine){
        foreach($new as $key=>$item){
            foreach($item as $key2=>$item2){
                $bets2 = $item2['bets'];
                $jine[$bets2] = $item2['zijibuhuo'];
                $yingkui[$bets2] = $zongjine-$jine[$bets2]*$item2['rate'];//预计盈亏  
            }
        }
        return $yingkui;
    }//盈亏变

    //查看实加外，实货加补货
    public function jinec5($new,$upoccupy){
        $keys = array_keys($upoccupy);
        foreach($new as $key=>$item){
            foreach($item as $key2=>$item2){
                for($i=0;$i<sizeof($keys);$i++){
                    if($item2['user_id']==$keys[$i]){
                        $upoccupy = $upoccupy[$keys[$i]];
                    }
                }
                $bets2 = $item2['bets'];
                $buhuojine[$bets2] = $item2['zijibuhuo'];
                $shihuojine[$bets2] += (($item2['price'])*$upoccupy)-$buhuo[$bets2];//实货
                $jine[$bets2] = $buhuojine[$bets2]+$shihuojine[$bets2];
            }
        }
        return $jine;
    }//金额变
    public function yingkuic5($new,$upoccupy){
        $keys = array_keys($upoccupy);
        foreach($new as $key=>$item){
            foreach($item as $key2=>$item2){
                for($i=0;$i<sizeof($keys);$i++){
                    if($item2['user_id']==$keys[$i]){
                        $upoccupy = $upoccupy[$keys[$i]];
                    }
                }
                $bets2 = $item2['bets'];
                $buhuojine[$bets2] = $item2['zijibuhuo'];
                $shihuojine[$bets2] += (($item2['price'])*$upoccupy)-$buhuo[$bets2];//实货
                $jine[$bets2] = $buhuojine[$bets2]+$shihuojine[$bets2];
                $yingkui[$bets2] = $zongjine-$jine[$bets2]*$item2['rate'];//预计盈亏  
            }
        }
        return $yingkui;
    }//盈亏变

    //即时注单特码(精简ok)(1个bet)
    public function injection(){
        $arr = model('orders')->findcount();
        foreach ($arr as $key11 => $item11) {
            $zongarr += $item11;
        }
        $new=array();
        $resultTema = model("rate")->findTemaRate();//特码赔率
        $announce = model('announce')->findstatus(2);     
        $panlei = $_GET["panlei"];
        $check = $_GET["check"];
        if($panlei == 0){
            $panlei = 1;
        }
        $datatime=$this->dangqianqishu();//判断当前期数
        $upoccupy = $this->zhaoupoccupy();
        $res = $this->quanbuzhudan($panlei,1,1,$item,$datatime);//特码A的全部注单
        $aaa = 0;
        foreach($res as $key => $item){
            if(!empty($item)){
                    $aaa += 1;
                    $zongjine = $this->zongjine($res);//特码总金额
                    $new = $this->betzhudan($res);//特码的1-49号球的注单以及特码三双大小那些
                    $a = array_keys($new);//提取数组下标 
                    $bishu = $this->bishuc0($new);
                    $buhuo = $this->buhuoc0($new);
                    $bishu2 = array_combine($a,$bishu);
                    $zongbishu = $this->zongbishu($bishu2);
                }else{
                    $aaa += 0;
                    $zongbishu = 0;//总笔数
                    $buhuo = array(0);//补货
                    $bishu2 = array(0);//笔数
                    $zongjine = 0;//总金额
                }
        }
        //根据check判断拿什么
        switch($check){
            case 0://查看全部
                if($aaa!=0){
                    $yingkui = $this->yingkuic0($new,$zongjine);
                    $jine = $this->jinec0($new);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);
                }                
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货
            break;
            case 1://查看实货就是成数减去自己补货出去的
                if($aaa!=0){
                    $jine = $this->jinec1($new,$upoccupy);
                    $yingkui = $this->yingkuic1($new,$zongjine,$upoccupy);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);
                }              
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货
            break;
            case 2://查看成数
                if($aaa!=0){
                    $jine = $this->jinec2($new,$upoccupy);
                    $yingkui = $this->yingkuic2($new,$zongjine,$upoccupy);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);
                }
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货  
            break;
            case 3://查看收补，看下级补货上来的 金额就是buhuo
                if($aaa!=0){
                    $jine = $this->jinec3($new);
                    $buhuo = $this->xiajibuhuo($new);
                    $yingkui = $this->yingkuic3($new,$zongjine);
                }else{
                    $jine = array(0);
                    $yingkui = array(0);
                    $buhuo = array(0);
                }
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货  
            break;
            case 4://查看补货，自己补货出去 这里补货就是金额
                if($aaa!=0){
                    $jine = $this->jinec4($new);
                    $yingkui = $this->yingkuic4($new,$zongjine);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);
                }
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货  
            break;
            case 5://查看实加外，实货加补货
                if($aaa!=0){            
                    $jine =  $this->jinec5($new,$upoccupy);
                    $yingkui = $this->yingkuic5($new,$upoccupy);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);                    
                }
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货
            break;
        }    

        $this->assign('res',$res);//全部符合条件的注单
        $this->assign('zongjine',$zongjine);//总价

        $this->assign('resultTema', $resultTema);//赔率
        $this->assign('datatime',$datatime);//期数
        $this->assign('announce',$announce);//广告
        $this->assign('arr',$arr);
        $this->assign('zongarr',$zongarr);
        // mp1($res);
        return $this->fetch();
    }

     //即时注单正码(精简ok)(1个bet)
    public function injectionzheng(){
        $arr = model('orders')->findcount();
        foreach ($arr as $key11 => $item11) {
            $zongarr += $item11;
        }
        $new=array();
        $resZhengma = model("rate")->findsZhengmaRate();//正码赔率      
        $resultTema = model("rate")->findTemaRate();//特码赔率
        $announce = model('announce')->findstatus(2);     
        $panlei = $_GET["panlei"];
        $check = $_GET["check"];
        if($panlei == 0){
            $panlei = 1;
        }
        $datatime=$this->dangqianqishu();//判断当前期数
        $upoccupy = $this->zhaoupoccupy();
        $res = $this->quanbuzhudan($panlei,2,1,$item,$datatime);//特码A的全部注单
        $aaa = 0;
        foreach($res as $key => $item){
            if(!empty($item)){
                    $aaa += 1;
                    $zongjine = $this->zongjine($res);//特码总金额
                    $new = $this->betzhudan($res);//特码的1-49号球的注单以及特码三双大小那些
                    $a = array_keys($new);//提取数组下标 
                    $bishu = $this->bishuc0($new);
                    $buhuo = $this->buhuoc0($new);
                    $bishu2 = array_combine($a,$bishu);
                    $zongbishu = $this->zongbishu($bishu2);
                }else{
                    $aaa += 0;
                    $zongbishu = 0;//总笔数
                    $buhuo = array(0);//补货
                    $bishu2 = array(0);//笔数
                    $zongjine = 0;//总金额
                }
        }
        //根据check判断拿什么
        switch($check){
            case 0://查看全部
                if($aaa!=0){
                    $yingkui = $this->yingkuic0($new,$zongjine);
                    $jine = $this->jinec0($new);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);
                }                
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货
            break;
            case 1://查看实货就是成数减去自己补货出去的
                if($aaa!=0){
                    $jine = $this->jinec1($new,$upoccupy);
                    $yingkui = $this->yingkuic1($new,$zongjine,$upoccupy);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);
                }              
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货
            break;
            case 2://查看成数
                if($aaa!=0){
                    $jine = $this->jinec2($new,$upoccupy);
                    $yingkui = $this->yingkuic2($new,$zongjine,$upoccupy);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);
                }
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货  
            break;
            case 3://查看收补，看下级补货上来的 金额就是buhuo
                if($aaa!=0){
                    $jine = $this->jinec3($new);
                    $buhuo = $this->xiajibuhuo($new);
                    $yingkui = $this->yingkuic3($new,$zongjine);
                }else{
                    $jine = array(0);
                    $yingkui = array(0);
                    $buhuo = array(0);
                }
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货  
            break;
            case 4://查看补货，自己补货出去 这里补货就是金额
                if($aaa!=0){
                    $jine = $this->jinec4($new);
                    $yingkui = $this->yingkuic4($new,$zongjine);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);
                }
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货  
            break;
            case 5://查看实加外，实货加补货
                if($aaa!=0){            
                    $jine =  $this->jinec5($new,$upoccupy);
                    $yingkui = $this->yingkuic5($new,$upoccupy);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);                    
                }
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货
            break;
        }    
        // mp1($zongbishu);
        // mp1($jine);
        // mp1($yingkui);
        // mp1($bishu2);
        // mp1($buhuo);
        $this->assign('res',$res);//全部符合条件的注单
        $this->assign('zongjine',$zongjine);//总价
        $this->assign('resZhengma', $resZhengma);//赔率
        $this->assign('resultTema',$resultTema);//赔率
        $this->assign('datatime',$datatime);//期数
        $this->assign('announce',$announce);//广告
        $this->assign('arr',$arr);
        $this->assign('zongarr',$zongarr);
        return $this->fetch();
    }

    //即时注单正码特(精简ok)(1个bet)
    public function injectionzmte(){
        $arr = model('orders')->findcount();
        foreach ($arr as $key11 => $item11) {
            $zongarr += $item11;
        }
        $new=array();
        $resZhengmaTeRate = model("rate")->findsZhengmaTeRate();//正码特赔率
        $announce = model('announce')->findstatus(2);     
        $panlei = $_GET["panlei"];
        $check = $_GET["check"];
        if($panlei == 0){
            $panlei = 1;
        }
        $datatime=$this->dangqianqishu();//判断当前期数
        $upoccupy = $this->zhaoupoccupy();
        $res = $this->quanbuzhudan($panlei,3,1,$item,$datatime);//特码A的全部注单
        $aaa = 0;
        foreach($res as $key => $item){
            if(!empty($item)){
                    $aaa += 1;
                    $zongjine = $this->zongjine($res);//特码总金额
                    $new = $this->betzhudan($res);//特码的1-49号球的注单以及特码三双大小那些
                    $a = array_keys($new);//提取数组下标 
                    $bishu = $this->bishuc0($new);
                    $buhuo = $this->buhuoc0($new);
                    $bishu2 = array_combine($a,$bishu);
                    $zongbishu = $this->zongbishu($bishu2);
                }else{
                    $aaa += 0;
                    $zongbishu = 0;//总笔数
                    $buhuo = array(0);//补货
                    $bishu2 = array(0);//笔数
                    $zongjine = 0;//总金额
                }
        }
        //根据check判断拿什么
        switch($check){
            case 0://查看全部
                if($aaa!=0){
                    $yingkui = $this->yingkuic0($new,$zongjine);
                    $jine = $this->jinec0($new);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);
                }                
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货
            break;
            case 1://查看实货就是成数减去自己补货出去的
                if($aaa!=0){
                    $jine = $this->jinec1($new,$upoccupy);
                    $yingkui = $this->yingkuic1($new,$zongjine,$upoccupy);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);
                }              
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货
            break;
            case 2://查看成数
                if($aaa!=0){
                    $jine = $this->jinec2($new,$upoccupy);
                    $yingkui = $this->yingkuic2($new,$zongjine,$upoccupy);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);
                }
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货  
            break;
            case 3://查看收补，看下级补货上来的 金额就是buhuo
                if($aaa!=0){
                    $jine = $this->jinec3($new);
                    $buhuo = $this->xiajibuhuo($new);
                    $yingkui = $this->yingkuic3($new,$zongjine);
                }else{
                    $jine = array(0);
                    $yingkui = array(0);
                    $buhuo = array(0);
                }
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货  
            break;
            case 4://查看补货，自己补货出去 这里补货就是金额
                if($aaa!=0){
                    $jine = $this->jinec4($new);
                    $yingkui = $this->yingkuic4($new,$zongjine);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);
                }
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货  
            break;
            case 5://查看实加外，实货加补货
                if($aaa!=0){            
                    $jine =  $this->jinec5($new,$upoccupy);
                    $yingkui = $this->yingkuic5($new,$upoccupy);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);                    
                }
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货
            break;
        }    

        $this->assign('res',$res);//全部符合条件的注单
        $this->assign('zongjine',$zongjine);//总价

        $this->assign('resZhengmaTeRate', $resZhengmaTeRate);//赔率
        $this->assign('announce',$announce);//广告
        $this->assign('arr',$arr);
        $this->assign('zongarr',$zongarr);
        // mp1($res);

        return $this->fetch();
    }

    //即时注单正码1-6(精简ok)(1个bet)
    public function injection1to6(){
        $arr = model('orders')->findcount();
        foreach ($arr as $key11 => $item11) {
            $zongarr += $item11;
        }
        $new=array();
        $resultZm1to6Rate = model("rate")->findsZm1to6Rate();//正码一到六赔率
        $announce = model('announce')->findstatus(2);     
        $panlei = $_GET["panlei"];
        $check = $_GET["check"];
        if($panlei == 0){
            $panlei = 1;
        }
        $datatime=$this->dangqianqishu();//判断当前期数
        $upoccupy = $this->zhaoupoccupy();
        $res = $this->quanbuzhudan($panlei,4,1,$item,$datatime);//特码A的全部注单
        $aaa = 0;
        foreach($res as $key => $item){
            if(!empty($item)){
                    $aaa += 1;
                    $zongjine = $this->zongjine($res);//特码总金额
                    $new = $this->betzhudan($res);//特码的1-49号球的注单以及特码三双大小那些
                    $a = array_keys($new);//提取数组下标 
                    $bishu = $this->bishuc0($new);
                    $buhuo = $this->buhuoc0($new);
                    $bishu2 = array_combine($a,$bishu);
                    $zongbishu = $this->zongbishu($bishu2);
                }else{
                    $aaa += 0;
                    $zongbishu = 0;//总笔数
                    $buhuo = array(0);//补货
                    $bishu2 = array(0);//笔数
                    $zongjine = 0;//总金额
                }
        }
        //根据check判断拿什么
        switch($check){
            case 0://查看全部
                if($aaa!=0){
                    $yingkui = $this->yingkuic0($new,$zongjine);
                    $jine = $this->jinec0($new);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);
                }                
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货
            break;
            case 1://查看实货就是成数减去自己补货出去的
                if($aaa!=0){
                    $jine = $this->jinec1($new,$upoccupy);
                    $yingkui = $this->yingkuic1($new,$zongjine,$upoccupy);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);
                }              
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货
            break;
            case 2://查看成数
                if($aaa!=0){
                    $jine = $this->jinec2($new,$upoccupy);
                    $yingkui = $this->yingkuic2($new,$zongjine,$upoccupy);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);
                }
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货  
            break;
            case 3://查看收补，看下级补货上来的 金额就是buhuo
                if($aaa!=0){
                    $jine = $this->jinec3($new);
                    $buhuo = $this->xiajibuhuo($new);
                    $yingkui = $this->yingkuic3($new,$zongjine);
                }else{
                    $jine = array(0);
                    $yingkui = array(0);
                    $buhuo = array(0);
                }
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货  
            break;
            case 4://查看补货，自己补货出去 这里补货就是金额
                if($aaa!=0){
                    $jine = $this->jinec4($new);
                    $yingkui = $this->yingkuic4($new,$zongjine);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);
                }
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货  
            break;
            case 5://查看实加外，实货加补货
                if($aaa!=0){            
                    $jine =  $this->jinec5($new,$upoccupy);
                    $yingkui = $this->yingkuic5($new,$upoccupy);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);                    
                }
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货
            break;
        }    

        $this->assign('res',$res);//全部符合条件的注单
        $this->assign('zongjine',$zongjine);//总价

        $this->assign('resultZm1to6Rate', $resultZm1to6Rate);//赔率        
        $this->assign('announce',$announce);//广告
        $this->assign('arr',$arr);
        $this->assign('zongarr',$zongarr);
        // mp1($res);

        return $this->fetch();
    }
//     public function injectionbanbo($andicap=1,$type=1,$upd=0){
//     // type=1 全部 2实货  3是成数 4是收补 5是补货 6实+补
//     // upd 1 2 3 4 更新
//     // andicap 盘口
//     $timeinterval = $this->timeinterval();
//     if($timeinterval==1){
//         $opentime = 1;
//     }else{        
//         $opentime = $timeinterval['opentime'];
//     }
//     $rate8 = array();
//     $rate9 = array();
//     $datatime = $this->dangqianqishu();
//     $announce = model('announce')->findstatus(2);
//     $ids = $this->id();
//     if($datatime==0){
//        $datatime = 0;             
//     }else{
//         foreach ($ids['u7'] as $key => $va) {
//             //拿当期所有7
//             $res8 = model('ordered')->finrede(1,8,$va,$datatime,session('adminid'));
//             $res9 = model('ordered')->finrede(1,9,$va,$datatime,session('adminid'));
//         }
//         foreach ($res9 as $key1 => $value1) {
//             if($value1['bets']>18){
//                 $res9[] = $value1;
//             } 
//         }
//         $res8 = $this->shuzucaozuo($res8);
//         $res9 = $this->shuzucaozuo($res9);
//         $res8 = json_decode($res8,true);
//         $res9 = json_decode($res9,true);
//     }
//     $opentime = 0;
//     $announce = model('announce')->findstatus(2);

//     $arr = model('orders')->findcount();
//     // mp($arr);

//     foreach ($arr as $key11 => $item11) {
//         $zongarr += $item11;
//     }
//     mp1($res8);
//     mp($res9);
//     $this->assign("andicap",$andicap);
//     $this->assign('upd',$upd);
//     $this->assign('res8',$res8);
//     $this->assign('res9',$res9);
//     $this->assign('datatime',$datatime);//期数
//     $this->assign('announce',$announce);//广告
//     $this->assign('arr',$arr);//上面的笔数
//     $this->assign('zongarr',$zongarr);//上面的总笔数 
//     $this->assign('opentime',$opentime);
//     return $this->fetch();
// }
    //即时注单半波七码(精简ok)(两个bet)    
    public function injectionbanbo(){
        //半波 bet=8 ,colums=1
        //七码 bet=9, colums=1
        //又要分两个写
        $arr = model('orders')->findcount();
                foreach ($arr as $key11 => $item11) {
            $zongarr += $item11;
        }
        $new=array();
        $announce = model('announce')->findstatus(2);  
        $resultBanBoRate = model("rate")->findsBanBoRate();//半波赔率
        $resultsevenRate = model("rate")->findssevenRate();//七码赔率
        $panlei = $_POST["panlei"];
        $check = $_POST["check"];
        $update = $_POST["update"];
        if($panlei == 0){
            $panlei = 1;
        }
        $datatime=$this->dangqianqishu();
        $uid=$this->id2();//id链

        $upoccupy = $this->zhaoupoccupy();
        //半波全部情况          
        $resbanbo = $this->quanbuzhudan($panlei,8,1,$item,$datatime);
        $aaa = 0;        
        foreach($resbanbo as $key => $item){
            if(!empty($item)){
                $aaa += 1;        
                $zongjinebanbo = $this->zongjine($resbanbo);//半波总金额
                $newbanbo = $this->betzhudan($resbanbo);//半波的bets
                $abanbo = array_keys($newbanbo);//提取数组下标
                // mp($abanbo);
                $bishubanbo = $this->bishuc0($newbanbo);
                // mp($bishubanbo);
                $buhuobanbo = $this->buhuoc0($newbanbo);//半波补货
                $bishu2banbo = array_combine($abanbo,$bishubanbo);//半波笔数
                $zongbishubanbo = $this->zongbishu($bishu2banbo);//半波总笔数
            }else{
                $aaa += 0;
                $bishu2banbo = array(0);//半波笔数
                $buhuobanbo = array(0);//半波补货
                $zongbishubanbo = array(0); //半波总笔数
                $zongjinebanbo = array(0);//半波总金额
            }
        }        
        // mp1($aaa);
        // mp1($bishu2banbo);
        // mp1($zongbishubanbo);
        // mp1($zongjinebanbo);
        // mp1("无");

        //七码全部情况        
        $resqima = $this->quanbuzhudan($panlei,9,1,$item,$datatime);
        $bbb = 0;
        foreach($resqima as $key => $item){
            if(!empty($item)){
                $bbb += 1;
                $zongjineqima = $this->zongjine($resqima);//七码总金额
                $newqima = $this->betzhudan($resqima);//七码的bets
                $aqima = array_keys($newqima);//提取数组下标
                $bishuqima = $this->bishuc0($newqima);
                $buhuoqima = $this->buhuoc0($newqima);//七码补货
                $bishu2qima = array_combine($aqima,$bishuqima);//七码笔数
                $zongbishuqima = $this->zongbishu($bishu2qima);//七码总笔数
            }else{
                $bbb += 0;
                $bishu2qima = array(0);//七码笔数
                $buhuoqima = array(0);//七码补货
                $zongbishuqima = array(0); //七码总笔数
                $zongjineqima = array(0);//七码总金额
            }
        }
        // mp1($bbb);
        // mp1($bishu2qima);
        // mp1($zongbishuqima);
        // mp1($zongjineqima);

        switch($check){
            case 0://查看全部
                //七码
                if($bbb!=0){
                    $yingkuiqima = $this->yingkuic0($newqima,$zongjineqima);//七码盈亏
                    $jineqima = $this->jinec0($newqima);//七码金额
                }else{
                    $yingkuiqima = array(0);//七码盈亏
                    $jineqima = array(0);//七码金额
                }

                //半波
                if($aaa!=0){
                    $yingkuibanbo = $this->yingkuic0($newbanbo,$zongjinebanbo);//半波盈亏
                    $jinebanbo = $this->jinec0($newbanbo);//半波金额
                }else{
                    $yingkuibanbo = array(0);//半波盈亏
                    $jinebanbo = array(0);//半波金额
                }

                $this->assign('zongbishuqima',$zongbishuqima);//七码总笔数
                $this->assign('jineqima',$jineqima);//七码金额
                $this->assign('yingkuiqima',$yingkuiqima);//七码盈亏
                $this->assign('bishuqima',$bishu2qima);//七码笔数
                $this->assign('buhuoqima',$buhuoqima);//七码补货
                $this->assign('zongbishubanbo',$zongbishubanbo);//半波总笔数
                $this->assign('jinebanbo',$jinebanbo);//半波金额
                $this->assign('yingkuibanbo',$yingkuibanbo);//半波盈亏
                $this->assign('bishubanbo',$bishu2banbo);//半波笔数
                $this->assign('buhuobanbo',$buhuobanbo);//半波补货
            break;

            case 1://查看实货就是成数减去自己补货出去的
                //七码
                if($bbb!=0){
                    $jineqima = $this->jinec1($newqima,$upoccupy);//七码金额
                    $yingkuiqima = $this->yingkuic1($newqima,$zongjineqima,$upoccupy);//七码盈亏
                }else{
                    $jineqima = array(0);//七码金额
                    $yingkuiqima = array(0);//七码盈亏
                }

                //半波
                if($aaa!=0){
                    $jinebanbo = $this->jinec1($newbanbo,$upoccupy);//半波金额
                    $yingkuibanbo = $this->yingkuic1($newbanbo,$zongjinebanbo,$upoccupy);//半波盈亏
                }else{
                    $jinebanbo = array(0);//半波金额
                    $yingkuibanbo = array(0);//半波盈亏
                }

                $this->assign('zongbishuqima',$zongbishuqima);//七码总笔数
                $this->assign('jineqima',$jineqima);//七码金额
                $this->assign('yingkuiqima',$yingkuiqima);//七码盈亏
                $this->assign('bishuqima',$bishu2qima);//七码笔数
                $this->assign('buhuoqima',$buhuoqima);//七码补货
                $this->assign('zongbishubanbo',$zongbishubanbo);//半波总笔数
                $this->assign('jinebanbo',$jinebanbo);//半波金额
                $this->assign('yingkuibanbo',$yingkuibanbo);//半波盈亏
                $this->assign('bishubanbo',$bishu2banbo);//半波笔数
                $this->assign('buhuobanbo',$buhuobanbo);//半波补货
            break;

            case 2://查看成数
                //七码
                if($bbb!=0){
                    $jineqima = $this->jinec2($newqima,$upoccupy);//七码金额
                    $yingkuiqima = $this->yingkuic2($newqima,$zongjineqima,$upoccupy);//七码盈亏
                }else{
                    $jineqima = array(0);//七码金额
                    $yingkuiqima = array(0);//七码盈亏
                }

                //半波
                if($aaa!=0){
                    $jinebanbo = $this->jinec2($newbanbo,$upoccupy);//半波金额
                    $yingkuibanbo = $this->yingkuic2($newbanbo,$zongjinebanbo,$upoccupy);//半波盈亏
                }else{
                    $jinebanbo = array(0);//半波金额
                    $yingkuibanbo = array(0);//半波盈亏
                }

                $this->assign('zongbishuqima',$zongbishuqima);//七码总笔数
                $this->assign('jineqima',$jineqima);//七码金额
                $this->assign('yingkuiqima',$yingkuiqima);//七码盈亏
                $this->assign('bishuqima',$bishu2qima);//七码笔数
                $this->assign('buhuoqima',$buhuoqima);//七码补货

                $this->assign('zongbishubanbo',$zongbishubanbo);//半波总笔数
                $this->assign('jinebanbo',$jinebanbo);//半波金额
                $this->assign('yingkuibanbo',$yingkuibanbo);//半波盈亏
                $this->assign('bishubanbo',$bishu2banbo);//半波笔数
                $this->assign('buhuobanbo',$buhuobanbo);//半波补货 
            break;
            case 3://查看收补，看下级补货上来的 金额就是buhuo
                //七码
                if($bbb!=0){
                    $jineqima = $this->jinec3($newqima);//七码金额
                    $buhuoqima = $this->xiajibuhuo($newqima);//七码补货
                    $yingkuiqima = $this->yingkuic3($newqima,$zongjineqima);//七码盈亏
                }else{
                    $jineqima = array(0);//七码金额
                    $buhuoqima = array(0);//七码补货
                    $yingkuiqima = array(0);//七码盈亏
                }

                //半波
                if($aaa!=0){
                    $jinebanbo = $this->jinec3($newbanbo);//半波金额
                    $buhuobanbo = $this->xiajibuhuo($newbanbo);//半波补货
                    $yingkuibanbo = $this->yingkuic3($newbanbo,$zongjinebanbo);//半波盈亏
                }else{
                    $jinebanbo = array(0);//半波金额
                    $buhuobanbo = array(0);//半波补货
                    $yingkuibanbo = array(0);//半波盈亏
                }

                $this->assign('zongbishuqima',$zongbishuqima);//七码总笔数
                $this->assign('jineqima',$jineqima);//七码金额
                $this->assign('yingkuiqima',$yingkuiqima);//七码盈亏
                $this->assign('bishuqima',$bishu2qima);//七码笔数
                $this->assign('buhuoqima',$buhuoqima);//七码补货

                $this->assign('zongbishubanbo',$zongbishubanbo);//半波总笔数
                $this->assign('jinebanbo',$jinebanbo);//半波金额
                $this->assign('yingkuibanbo',$yingkuibanbo);//半波盈亏
                $this->assign('bishubanbo',$bishu2banbo);//半波笔数
                $this->assign('buhuobanbo',$buhuobanbo);//半波补货  
            break;

            case 4://查看补货，自己补货出去 这里补货就是金额

                //七码
                if($bbb!=0){
                    $jineqima = $this->jinec4($newqima);//七码金额
                    $yingkuiqima = $this->yingkuic4($newqima,$zongjineqima);//七码盈亏
                }else{
                    $jineqima = array(0);//七码金额
                    $yingkuiqima = array(0);//七码盈亏
                }

                //半波
                if($aaa!=0){
                    $jinebanbo = $this->jinec4($newbanbo);//半波金额
                    $yingkuibanbo = $this->yingkuic4($newbanbo,$zongjinebanbo);//半波盈亏
                }else{
                    $jinebanbo = array(0);//半波金额
                    $yingkuibanbo = array(0);//半波盈亏
                }

                $this->assign('zongbishuqima',$zongbishuqima);//七码总笔数
                $this->assign('jineqima',$jineqima);//七码金额
                $this->assign('yingkuiqima',$yingkuiqima);//七码盈亏
                $this->assign('bishuqima',$bishu2qima);//七码笔数
                $this->assign('buhuoqima',$buhuoqima);//七码补货

                $this->assign('zongbishubanbo',$zongbishubanbo);//半波总笔数
                $this->assign('jinebanbo',$jinebanbo);//半波金额
                $this->assign('yingkuibanbo',$yingkuibanbo);//半波盈亏
                $this->assign('bishubanbo',$bishu2banbo);//半波笔数
                $this->assign('buhuobanbo',$buhuobanbo);//半波补货
            break;
            case 5://查看实加外，实货加补货
                //七码
                if($bbb!=0){
                    $jineqima =  $this->jinec5($newqima,$upoccupy);//七码金额
                    $yingkuiqima = $this->yingkuic5($newqima,$upoccupy);//七码盈亏
                }else{
                    $jineqima = array(0);//七码金额
                    $yingkuiqima = array(0);//七码盈亏
                }

                //半波
                if($aaa!=0){
                    $jinebanbo =  $this->jinec5($newbanbo,$upoccupy);//半波金额
                    $yingkuibanbo = $this->yingkuic5($newbanbo,$upoccupy);//半波盈亏
                }else{
                    $jinebanbo = arrray(0);//半波金额
                    $yingkuibanbo = arrray(0);//半波盈亏
                }

                $this->assign('zongbishuqima',$zongbishuqima);//七码总笔数
                $this->assign('jineqima',$jineqima);//七码金额
                $this->assign('yingkuiqima',$yingkuiqima);//七码盈亏
                $this->assign('bishuqima',$bishu2qima);//七码笔数
                $this->assign('buhuoqima',$buhuoqima);//七码补货

                $this->assign('zongbishubanbo',$zongbishubanbo);//半波总笔数
                $this->assign('jinebanbo',$jinebanbo);//半波金额
                $this->assign('yingkuibanbo',$yingkuibanbo);//半波盈亏
                $this->assign('bishubanbo',$bishu2banbo);//半波笔数
                $this->assign('buhuobanbo',$buhuobanbo);//半波补货
            break;
        }
        $this->assign('resbanbo',$resbanbo);//全部符合条件的半波注单
        $this->assign('zongjinebanbo',$zongjinebanbo);//半波总价
        $this->assign('resqima',$resqima);//全部符合条件的七码注单
        $this->assign('zongjineqima',$zongjineqima);//七码总价
        $this->assign('BanBoRate', $resultBanBoRate);//半波赔率
        $this->assign('sevenRate', $resultsevenRate);//七码赔率
        $this->assign('datatime',$datatime);//期数
        $this->assign('announce',$announce);//广告
        $this->assign('arr',$arr);
        $this->assign('zongarr',$zongarr);
        // mp1($yingkuibanbo);
        // mp1($jinebanbo);
        // mp1($yingkuiqima);
        // mp1($jineqima);
        return $this->fetch();
    }

    //即时注单生肖头尾数(精简ok)(1个bet)
    public function injectiontws(){
        $arr = model('orders')->findcount();
        foreach ($arr as $key11 => $item11) {
            $zongarr += $item11;
        }
        $new=array();
        $resultTemaSXTWRate = model("rate")->findsTemaSXTWRate();//特码生肖头尾赔率
        $announce = model('announce')->findstatus(2);     
        $panlei = $_GET["panlei"];
        $check = $_GET["check"];
        if($panlei == 0){
            $panlei = 1;
        }
        $datatime=$this->dangqianqishu();//判断当前期数
        $upoccupy = $this->zhaoupoccupy();
        $res = $this->quanbuzhudan($panlei,6,1,$item,$datatime);//特码A的全部注单
        $aaa = 0;
        foreach($res as $key => $item){
            if(!empty($item)){
                    $aaa += 1;
                    $zongjine = $this->zongjine($res);//特码总金额
                    $new = $this->betzhudan($res);//特码的1-49号球的注单以及特码三双大小那些
                    $a = array_keys($new);//提取数组下标 
                    $bishu = $this->bishuc0($new);
                    $buhuo = $this->buhuoc0($new);
                    $bishu2 = array_combine($a,$bishu);
                    $zongbishu = $this->zongbishu($bishu2);
                }else{
                    $aaa += 0;
                    $zongbishu = 0;//总笔数
                    $buhuo = array(0);//补货
                    $bishu2 = array(0);//笔数
                    $zongjine = 0;//总金额
                }
        }
        //根据check判断拿什么
        switch($check){
            case 0://查看全部
                if($aaa!=0){
                    $yingkui = $this->yingkuic0($new,$zongjine);
                    $jine = $this->jinec0($new);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);
                }                
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货
            break;
            case 1://查看实货就是成数减去自己补货出去的
                if($aaa!=0){
                    $jine = $this->jinec1($new,$upoccupy);
                    $yingkui = $this->yingkuic1($new,$zongjine,$upoccupy);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);
                }              
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货
            break;
            case 2://查看成数
                if($aaa!=0){
                    $jine = $this->jinec2($new,$upoccupy);
                    $yingkui = $this->yingkuic2($new,$zongjine,$upoccupy);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);
                }
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货  
            break;
            case 3://查看收补，看下级补货上来的 金额就是buhuo
                if($aaa!=0){
                    $jine = $this->jinec3($new);
                    $buhuo = $this->xiajibuhuo($new);
                    $yingkui = $this->yingkuic3($new,$zongjine);
                }else{
                    $jine = array(0);
                    $yingkui = array(0);
                    $buhuo = array(0);
                }
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货  
            break;
            case 4://查看补货，自己补货出去 这里补货就是金额
                if($aaa!=0){
                    $jine = $this->jinec4($new);
                    $yingkui = $this->yingkuic4($new,$zongjine);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);
                }
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货  
            break;
            case 5://查看实加外，实货加补货
                if($aaa!=0){            
                    $jine =  $this->jinec5($new,$upoccupy);
                    $yingkui = $this->yingkuic5($new,$upoccupy);
                }else{
                    $yingkui = array(0);
                    $jine = array(0);                    
                }
                $this->assign('zongbishu',$zongbishu);//总笔数
                $this->assign('jine',$jine);//金额
                $this->assign('yingkui',$yingkui);//盈亏
                $this->assign('bishu',$bishu2);//笔数
                $this->assign('buhuo',$buhuo);//补货
            break;
        }    

        $this->assign('res',$res);//全部符合条件的注单
        $this->assign('zongjine',$zongjine);//总价

        $this->assign('resultTemaSXTWRate',$resultTemaSXTWRate);//赔率
        $this->assign('announce',$announce);//广告
        $this->assign('arr',$arr);
        $this->assign('zongarr',$zongarr);
        // mp1($res);

        return $this->fetch();
    }

    //即时注单正特多选项(精简ok)(3个bet)
    // public function injectiondxx(){
    //     //连肖 bet=10 ,colums=1 
    //     //多肖 bet=12, colums=1 
    //     //正码过关 bet = 5 ,colums = 1
    //     //又要分3个写
    //     $arr = model('orders')->findcount();
    //     foreach ($arr as $key11 => $item11) {
    //         $zongarr += $item11;
    //     }
    //     $new=array();
    //     $announce = model('announce')->findstatus(2);
    //     $reslianxiaorate = model("rate")->finds(10);//连肖赔率
    //     $resduoxiaorate = model("rate")->finds12();//多肖赔率
    //     $res10 = model("rate")->finds(10);//10连肖 要
    //     $resweishulianRate = model("rate")->findsweishulianRate();//连肖赔率 要
    //     $resultZTDXXduoxiaoRate = model("rate")->findsZTDXXduoxiaoRate();//正特多选项 要
    //     $resultZMGGRate = model("rate")->findsZMGGRate();//正码过关赔率 要
    //     $panlei = $_POST["panlei"];
    //     $check = $_POST["check"];
    //     $update = $_POST["update"];
    //     if($panlei == 0){$panlei = 1;}
    //     $datatime=$this->dangqianqishu();
    //     $uid=$this->id2();//id链

    //     $upoccupy = $this->zhaoupoccupy();
    //     //连肖全部情况          
    //     $resbanbo = $this->quanbuzhudan($panlei,10,1,$item,$datatime);
    //     $aaa = 0;        
    //     foreach($resbanbo as $key => $item){
    //         if(!empty($item)){
    //             $aaa += 1;
    //             $zongjinebanbo = $this->zongjine($resbanbo);//连肖总金额
    //             $newbanbo = $this->betzhudan($resbanbo);//连肖的bets
    //             $abanbo = array_keys($newbanbo);//提取数组下标
    //             $bishubanbo = $this->bishuc0($newbanbo);
    //             $buhuobanbo = $this->buhuoc0($newbanbo);//连肖补货
    //             $bishu2banbo = array_combine($abanbo,$bishubanbo);//连肖笔数
    //             $zongbishubanbo = $this->zongbishu($bishu2banbo);//连肖总笔数
    //         }else{
    //             $aaa += 0;
    //             $bishu2banbo = array(0);//连肖笔数
    //             $buhuobanbo = array(0);//连肖补货
    //             $zongbishubanbo = array(0); //连肖总笔数
    //             $zongjinebanbo = array(0);//连肖总金额
    //         }
    //     }        

    //     //多肖全部情况        
    //     $resqima = $this->quanbuzhudan($panlei,12,1,$item,$datatime);
    //     $sss = 0;        
    //     foreach($resqima as $ky => $item1){
    //         if(!empty($item1)){
    //             $sss += 1;
    //             $zongjineqima = $this->zongjine($resqima);//多肖总金额
    //             $newqima = $this->betzhudan($resqima);//多肖的bets
    //             $aqima = array_keys($newqima);//提取数组下标
    //             $bishuqima = $this->bishuc0($newqima);
    //             $buhuoqima = $this->buhuoc0($newqima);//多肖补货
    //             $bishu2qima = array_combine($aqima,$bishuqima);//多肖笔数
    //             $zongbishuqima = $this->zongbishu($bishu2qima);//多肖总笔数
    //         }else{
    //             $sss += 0;
    //             $bishu2qima = array(0);//多肖笔数
    //             $buhuoqima = array(0);//多肖补货
    //             $zongbishuqima = array(0); //多肖总笔数
    //             $zongjineqima = array(0);//多肖总金额
    //         }
    //     }

    //     //正码过关
    //     $reszmgg = $this->quanbuzhudan($panlei,5,1,$item,$datatime);
    //     $zzz = 0;        
    //     foreach($reszmgg as $ky => $item1){
    //         if(!empty($item1)){
    //             $zzz += 1;
    //             $zongjinezmgg = $this->zongjine($reszmgg);//正码过关总金额
    //             $newzmgg = $this->betzhudan($reszmgg);//正码过关的bets
    //             $azmgg = array_keys($newzmgg);//提取数组下标
    //             $bishuzmgg = $this->bishuc0($newzmgg);
    //             $buhuozmgg = $this->buhuoc0($newzmgg);//正码过关补货
    //             $bishu2zmgg = array_combine($azmgg,$bishuzmgg);//正码过关笔数
    //             $zongbishuzmgg = $this->zongbishu($bishu2zmgg);//正码过关总笔数
    //         }else{
    //             $zzz += 0;
    //             $bishu2zmgg = array(0);//正码过关笔数
    //             $buhuozmgg = array(0);//正码过关补货
    //             $zongbishuzmgg = array(0); //正码过关总笔数
    //             $zongjinezmgg = array(0);//正码过关总金额
    //         }
    //     }

    //     switch($check){
    //         case 0://查看全部

    //             //多肖
    //             if($sss!=0){
    //                 $yingkuiqima = $this->yingkuic0($newqima,$zongjineqima);//多肖盈亏
    //                 $jineqima = $this->jinec0($newqima);//多肖金额
    //             }else{
    //                 $yingkuiqima = array(0);//多肖盈亏
    //                 $jineqima = array(0);//多肖金额
    //             }

    //             //连肖
    //             if($aaa!=0){
    //                 $yingkuibanbo = $this->yingkuic0($newbanbo,$zongjinebanbo);//连肖盈亏
    //                 $jinebanbo = $this->jinec0($newbanbo);//连肖金额
    //             }else{
    //                 $yingkuibanbo = array(0);//连肖盈亏
    //                 $jinebanbo = array(0);//连肖金额
    //             }

    //             //正码过关
    //             if($zzz!=0){
    //                 $yingkuizmgg = $this->yingkuic0($newzmgg,$zongjinezmgg);//连肖盈亏
    //                 $jinezmgg = $this->jinec0($newzmgg);//连肖金额
    //             }else{
    //                 $yingkuizmgg = array(0);//连肖盈亏
    //                 $jinezmgg = array(0);//连肖金额
    //             }
                
    //             $this->assign('zongbishuqima',$zongbishuqima);//多肖总笔数
    //             $this->assign('jineqima',$jineqima);//多肖金额
    //             $this->assign('yingkuiqima',$yingkuiqima);//多肖盈亏
    //             $this->assign('bishuqima',$bishu2qima);//多肖笔数
    //             $this->assign('buhuoqima',$buhuoqima);//多肖补货

    //             $this->assign('zongbishuzmgg',$zongbishuzmgg);//正码过关总笔数
    //             $this->assign('jinezmgg',$jinezmgg);//正码过关金额
    //             $this->assign('yingkuizmgg',$yingkuizmgg);//正码过关盈亏
    //             $this->assign('bishuzmgg',$bishu2zmgg);//正码过关笔数
    //             $this->assign('buhuozmgg',$buhuozmgg);//正码过关补货

    //             $this->assign('zongbishubanbo',$zongbishubanbo);//连肖总笔数
    //             $this->assign('jinebanbo',$jinebanbo);//连肖金额
    //             $this->assign('yingkuibanbo',$yingkuibanbo);//连肖盈亏
    //             $this->assign('bishubanbo',$bishu2banbo);//连肖笔数
    //             $this->assign('buhuobanbo',$buhuobanbo);//连肖补货
    //         break;

    //         case 1://查看实货就是成数减去自己补货出去的

    //             //多肖
    //             if($sss!=0){
    //                 $jineqima = $this->jinec1($newqima,$upoccupy);//多肖金额
    //                 $yingkuiqima = $this->yingkuic1($newqima,$zongjineqima,$upoccupy);//多肖盈亏
    //             }else{
    //                 $jineqima = array(0);//多肖金额
    //                 $yingkuiqima = array(0);//多肖盈亏
    //             }

    //             //连肖
    //             if($aaa!=0){
    //                 $jinebanbo = $this->jinec1($newbanbo,$upoccupy);//连肖金额
    //                 $yingkuibanbo = $this->yingkuic1($newbanbo,$zongjinebanbo,$upoccupy);//连肖盈亏
    //             }else{
    //                 $jinebanbo = array(0);//连肖金额
    //                 $yingkuibanbo = array(0);//连肖盈亏
    //             }

    //             //正码过关
    //             if($zzz!=0){
    //                 $jinezmgg = $this->jinec1($newzmgg,$upoccupy);//正码过关金额
    //                 $yingkuizmgg = $this->yingkuic1($newzmgg,$zongjinezmgg,$upoccupy);//正码过关盈亏
    //             }else{
    //                 $jinezmgg = array(0);//正码过关金额
    //                 $yingkuizmgg = array(0);//正码过关盈亏
    //             }

    //             $this->assign('zongbishuqima',$zongbishuqima);//多肖总笔数
    //             $this->assign('jineqima',$jineqima);//多肖金额
    //             $this->assign('yingkuiqima',$yingkuiqima);//多肖盈亏
    //             $this->assign('bishuqima',$bishu2qima);//多肖笔数
    //             $this->assign('buhuoqima',$buhuoqima);//多肖补货

    //             $this->assign('zongbishuzmgg',$zongbishuzmgg);//正码过关总笔数
    //             $this->assign('jinezmgg',$jinezmgg);//正码过关金额
    //             $this->assign('yingkuizmgg',$yingkuizmgg);//正码过关盈亏
    //             $this->assign('bishuzmgg',$bishu2zmgg);//正码过关笔数
    //             $this->assign('buhuozmgg',$buhuozmgg);//正码过关补货

    //             $this->assign('zongbishubanbo',$zongbishubanbo);//连肖总笔数
    //             $this->assign('jinebanbo',$jinebanbo);//连肖金额
    //             $this->assign('yingkuibanbo',$yingkuibanbo);//连肖盈亏
    //             $this->assign('bishubanbo',$bishu2banbo);//连肖笔数
    //             $this->assign('buhuobanbo',$buhuobanbo);//连肖补货
    //         break;
    //         case 2://查看成数

    //             //多肖
    //             if($sss!=0){
    //                 $jineqima = $this->jinec2($newqima,$upoccupy);//多肖金额
    //                 $yingkuiqima = $this->yingkuic2($newqima,$zongjineqima,$upoccupy);//多肖盈亏
    //             }else{
    //                 $jineqima = array(0);//多肖金额
    //                 $yingkuiqima = array(0);//多肖盈亏
    //             }

    //             //连肖
    //             if($aaa!=0){
    //                 $jinebanbo = $this->jinec2($newbanbo,$upoccupy);//连肖金额
    //                 $yingkuibanbo = $this->yingkuic2($newbanbo,$zongjinebanbo,$upoccupy);//连肖盈亏
    //             }else{
    //                 $jinebanbo = array(0);//连肖金额
    //                 $yingkuibanbo = array(0);//连肖盈亏
    //             }

    //             //正码过关
    //             if($zzz!=0){
    //                 $jinezmgg = $this->jinec2($newzmgg,$upoccupy);//正码过关金额
    //                 $yingkuizmgg = $this->yingkuic2($newzmgg,$zongjinezmgg,$upoccupy);//正码过关盈亏
    //             }else{
    //                 $jinezmgg = array(0);//正码过关金额
    //                 $yingkuizmgg = array(0);//正码过关盈亏
    //             }

    //             $this->assign('zongbishuqima',$zongbishuqima);//多肖总笔数
    //             $this->assign('jineqima',$jineqima);//多肖金额
    //             $this->assign('yingkuiqima',$yingkuiqima);//多肖盈亏
    //             $this->assign('bishuqima',$bishu2qima);//多肖笔数
    //             $this->assign('buhuoqima',$buhuoqima);//多肖补货

    //             $this->assign('zongbishuzmgg',$zongbishuzmgg);//正码过关总笔数
    //             $this->assign('jinezmgg',$jinezmgg);//正码过关金额
    //             $this->assign('yingkuizmgg',$yingkuizmgg);//正码过关盈亏
    //             $this->assign('bishuzmgg',$bishu2zmgg);//正码过关笔数
    //             $this->assign('buhuozmgg',$buhuozmgg);//正码过关补货

    //             $this->assign('zongbishubanbo',$zongbishubanbo);//连肖总笔数
    //             $this->assign('jinebanbo',$jinebanbo);//连肖金额
    //             $this->assign('yingkuibanbo',$yingkuibanbo);//连肖盈亏
    //             $this->assign('bishubanbo',$bishu2banbo);//连肖笔数
    //             $this->assign('buhuobanbo',$buhuobanbo);//连肖补货
    //         break;
    //         case 3://查看收补，看下级补货上来的 金额就是buhuo

    //             //多肖
    //             if($sss!=0){
    //                 $jineqima = $this->jinec3($newqima);//多肖金额
    //                 $buhuoqima = $this->xiajibuhuo($newqima);//多肖补货
    //                 $yingkuiqima = $this->yingkuic3($newqima,$zongjineqima);//多肖盈亏
    //             }else{
    //                 $jineqima = array(0);//多肖金额
    //                 $buhuoqima = array(0);//多肖补货
    //                 $yingkuiqima = array(0);//多肖盈亏
    //             }

    //             //连肖
    //             if($aaa!=0){
    //                 $jinebanbo = $this->jinec3($newbanbo);//连肖金额
    //                 $buhuobanbo = $this->xiajibuhuo($newbanbo);//连肖补货
    //                 $yingkuibanbo = $this->yingkuic3($newbanbo,$zongjinebanbo);//连肖盈亏
    //             }else{
    //                 $jinebanbo = array(0);//连肖金额
    //                 $buhuobanbo = array(0);//连肖补货
    //                 $yingkuibanbo = array(0);//连肖盈亏
    //             }

    //             //正码过关
    //             if($zzz!=0){
    //                 $jinezmgg = $this->jinec3($newzmgg);//正码过关金额
    //                 $buhuozmgg = $this->xiajibuhuo($newzmgg);//正码过关补货
    //                 $yingkuizmgg = $this->yingkuic3($newzmgg,$zongjinezmgg);//正码过关盈亏
    //             }else{
    //                 $jinezmgg = array(0);//正码过关金额
    //                 $buhuozmgg = array(0);//正码过关补货
    //                 $yingkuizmgg = array(0);//正码过关盈亏
    //             }                

    //             $this->assign('zongbishuqima',$zongbishuqima);//多肖总笔数
    //             $this->assign('jineqima',$jineqima);//多肖金额
    //             $this->assign('yingkuiqima',$yingkuiqima);//多肖盈亏
    //             $this->assign('bishuqima',$bishu2qima);//多肖笔数
    //             $this->assign('buhuoqima',$buhuoqima);//多肖补货

    //             $this->assign('zongbishuzmgg',$zongbishuzmgg);//正码过关总笔数
    //             $this->assign('jinezmgg',$jinezmgg);//正码过关金额
    //             $this->assign('yingkuizmgg',$yingkuizmgg);//正码过关盈亏
    //             $this->assign('bishuzmgg',$bishu2zmgg);//正码过关笔数
    //             $this->assign('buhuozmgg',$buhuozmgg);//正码过关补货

    //             $this->assign('zongbishubanbo',$zongbishubanbo);//连肖总笔数
    //             $this->assign('jinebanbo',$jinebanbo);//连肖金额
    //             $this->assign('yingkuibanbo',$yingkuibanbo);//连肖盈亏
    //             $this->assign('bishubanbo',$bishu2banbo);//连肖笔数
    //             $this->assign('buhuobanbo',$buhuobanbo);//连肖补货  
    //         break;
    //         case 4://查看补货，自己补货出去 这里补货就是金额

    //             //多肖
    //             if($sss!=0){
    //                 $jineqima = $this->jinec4($newqima);//多肖金额
    //                 $yingkuiqima = $this->yingkuic4($newqima,$zongjineqima);//多肖盈亏
    //             }else{
    //                 $jineqima = array(0);//多肖金额
    //                 $yingkuiqima = array(0);//多肖盈亏
    //             }

    //             //连肖
    //             if($aaa!=0){
    //                 $jinebanbo = $this->jinec4($newbanbo);//连肖金额
    //                 $yingkuibanbo = $this->yingkuic4($newbanbo,$zongjinebanbo);//连肖盈亏
    //             }else{
    //                 $jinebanbo = array(0);//连肖金额
    //                 $yingkuibanbo = array(0);//连肖盈亏
    //             }

    //             //正码过关
    //             if($zzz!=0){
    //                 $jinezmgg = $this->jinec4($newzmgg);//正码过关金额
    //                 $yingkuizmgg = $this->yingkuic4($newzmgg,$zongjinezmgg);//正码过关盈亏
    //             }else{
    //                 $jinezmgg = array(0);//正码过关金额
    //                 $yingkuizmgg = array(0);//正码过关盈亏
    //             }

    //             $this->assign('zongbishuqima',$zongbishuqima);//多肖总笔数
    //             $this->assign('jineqima',$jineqima);//多肖金额
    //             $this->assign('yingkuiqima',$yingkuiqima);//多肖盈亏
    //             $this->assign('bishuqima',$bishu2qima);//多肖笔数
    //             $this->assign('buhuoqima',$buhuoqima);//多肖补货

    //             $this->assign('zongbishuzmgg',$zongbishuzmgg);//正码过关总笔数
    //             $this->assign('jinezmgg',$jinezmgg);//正码过关金额
    //             $this->assign('yingkuizmgg',$yingkuizmgg);//正码过关盈亏
    //             $this->assign('bishuzmgg',$bishu2zmgg);//正码过关笔数
    //             $this->assign('buhuozmgg',$buhuozmgg);//正码过关补货

    //             $this->assign('zongbishubanbo',$zongbishubanbo);//连肖总笔数
    //             $this->assign('jinebanbo',$jinebanbo);//连肖金额
    //             $this->assign('yingkuibanbo',$yingkuibanbo);//连肖盈亏
    //             $this->assign('bishubanbo',$bishu2banbo);//连肖笔数
    //             $this->assign('buhuobanbo',$buhuobanbo);//连肖补货
    //         break;
    //         case 5://查看实加外，实货加补货

    //             //多肖
    //             if($sss!=0){
    //                 $jineqima =  $this->jinec5($newqima,$upoccupy);//多肖金额
    //                 $yingkuiqima = $this->yingkuic5($newqima,$upoccupy);//多肖盈亏
    //             }else{
    //                 $jineqima = array(0);//多肖金额
    //                 $yingkuiqima = array(0);//多肖盈亏
    //             }

    //             //连肖
    //             if($aaa!=0){
    //                 $jinebanbo =  $this->jinec5($newbanbo,$upoccupy);//连肖金额
    //                 $yingkuibanbo = $this->yingkuic5($newbanbo,$upoccupy);//连肖盈亏
    //             }else{
    //                 $jinebanbo = array(0);//连肖金额
    //                 $yingkuibanbo = array(0);//连肖盈亏
    //             }

    //             //正码过关
    //             if($zzz!=0){
    //                 $jinezmgg =  $this->jinec5($newzmgg,$upoccupy);//正码过关金额
    //                 $yingkuizmgg = $this->yingkuic5($newzmgg,$upoccupy);//正码过关盈亏
    //             }else{
    //                 $jinezmgg = array(0);//正码过关金额
    //                 $yingkuizmgg = array(0);//正码过关盈亏
    //             }

    //             $this->assign('zongbishuqima',$zongbishuqima);//多肖总笔数
    //             $this->assign('jineqima',$jineqima);//多肖金额
    //             $this->assign('yingkuiqima',$yingkuiqima);//多肖盈亏
    //             $this->assign('bishuqima',$bishu2qima);//多肖笔数
    //             $this->assign('buhuoqima',$buhuoqima);//多肖补货

    //             $this->assign('zongbishuzmgg',$zongbishuzmgg);//正码过关总笔数
    //             $this->assign('jinezmgg',$jinezmgg);//正码过关金额
    //             $this->assign('yingkuizmgg',$yingkuizmgg);//正码过关盈亏
    //             $this->assign('bishuzmgg',$bishu2zmgg);//正码过关笔数
    //             $this->assign('buhuozmgg',$buhuozmgg);//正码过关补货

    //             $this->assign('zongbishubanbo',$zongbishubanbo);//连肖总笔数
    //             $this->assign('jinebanbo',$jinebanbo);//连肖金额
    //             $this->assign('yingkuibanbo',$yingkuibanbo);//连肖盈亏
    //             $this->assign('bishubanbo',$bishu2banbo);//连肖笔数
    //             $this->assign('buhuobanbo',$buhuobanbo);//连肖补货
    //         break;
    //     }
    //     $this->assign('resbanbo',$resbanbo);//全部符合条件的连肖注单
    //     $this->assign('zongjinebanbo',$zongjinebanbo);//连肖总价
    //     $this->assign('resqima',$resqima);//全部符合条件的多肖注单
    //     $this->assign('zongjineqima',$zongjineqima);//多肖总价
    //     $this->assign('reszmgg',$reszmgg);//全部符合条件的正码过关注单
    //     $this->assign('zongjinezmgg',$zongjinezmgg);//正码过关总价

    //     $this->assign('reslianxiaorate', $reslianxiaorate);//特码连肖赔率
    //     $this->assign('resduoxiaorate', $resduoxiaorate);//特码多肖赔率 
    //     $this->assign('resultZTDXXduoxiaoRate', $resultZTDXXduoxiaoRate);
    //     $this->assign('resweishulianRate', $resweishulianRate);
    //     $this->assign('res10', $res10);
    //     $this->assign('resultZMGGRate',$resultZMGGRate);
    //     $this->assign('datatime',$datatime);//期数
    //     $this->assign('announce',$announce);//广告
    //     $this->assign('arr',$arr);//上面的笔数
    //     $this->assign('zongarr',$zongarr);//上面的总笔数

    //     mp1($zongbishubanbo);
    //     mp1($jinebanbo);
    //     mp1($yingkuibanbo);
    //     mp1($bishu2banbo);
    //     mp1($buhuobanbo);
    //     mp1($zongjinebanbo);
    //     return $this->fetch();
    // }

    //即时注单连码(精简ok)(1个bet)
    // public function injectionlianma(){
    //     $arr = model('orders')->findcount();
    //     foreach ($arr as $key11 => $item11) {
    //         $zongarr += $item11;
    //     }
    //     $new=array();
    //     $resultSQZRate = model("rate")->findsSQZRate();//三全中赔率        
    //     $announce = model('announce')->findstatus(2);     
    //     $panlei = $_GET["panlei"];
    //     $check = $_GET["check"];
    //     if($panlei == 0){
    //         $panlei = 1;
    //     }
    //     $datatime=$this->dangqianqishu();//判断当前期数
    //     $upoccupy = $this->zhaoupoccupy();
    //     $res = $this->quanbuzhudan($panlei,7,1,$item,$datatime);//
    //     mp($res);
    //     $aaa = 0;
    //     foreach($res as $key => $item){
    //         if(!empty($item)){
    //                 $aaa += 1;
    //                 $zongjine = $this->zongjine($res);//
    //                 $new = $this->betzhudan($res);//
    //                 $a = array_keys($new);// 
    //                 $bishu = $this->bishuc0($new);
    //                 $buhuo = $this->buhuoc0($new);
    //                 $bishu2 = array_combine($a,$bishu);
    //                 $zongbishu = $this->zongbishu($bishu2);
    //             }else{
    //                 $aaa += 0;
    //                 $zongbishu = 0;//总笔数
    //                 $buhuo = array(0);//补货
    //                 $bishu2 = array(0);//笔数
    //                 $zongjine = 0;//总金额
    //             }
    //     }
    //     //根据check判断拿什么
    //     switch($check){
    //         case 0://查看全部
    //             if($aaa!=0){
    //                 $yingkui = $this->yingkuic0($new,$zongjine);
    //                 $jine = $this->jinec0($new);
    //             }else{
    //                 $yingkui = array(0);
    //                 $jine = array(0);
    //             }                
    //             $this->assign('zongbishu',$zongbishu);//总笔数
    //             $this->assign('jine',$jine);//金额
    //             $this->assign('yingkui',$yingkui);//盈亏
    //             $this->assign('bishu',$bishu2);//笔数
    //             $this->assign('buhuo',$buhuo);//补货
    //         break;
    //         case 1://查看实货就是成数减去自己补货出去的
    //             if($aaa!=0){
    //                 $jine = $this->jinec1($new,$upoccupy);
    //                 $yingkui = $this->yingkuic1($new,$zongjine,$upoccupy);
    //             }else{
    //                 $yingkui = array(0);
    //                 $jine = array(0);
    //             }              
    //             $this->assign('zongbishu',$zongbishu);//总笔数
    //             $this->assign('jine',$jine);//金额
    //             $this->assign('yingkui',$yingkui);//盈亏
    //             $this->assign('bishu',$bishu2);//笔数
    //             $this->assign('buhuo',$buhuo);//补货
    //         break;
    //         case 2://查看成数
    //             if($aaa!=0){
    //                 $jine = $this->jinec2($new,$upoccupy);
    //                 $yingkui = $this->yingkuic2($new,$zongjine,$upoccupy);
    //             }else{
    //                 $yingkui = array(0);
    //                 $jine = array(0);
    //             }
    //             $this->assign('zongbishu',$zongbishu);//总笔数
    //             $this->assign('jine',$jine);//金额
    //             $this->assign('yingkui',$yingkui);//盈亏
    //             $this->assign('bishu',$bishu2);//笔数
    //             $this->assign('buhuo',$buhuo);//补货  
    //         break;
    //         case 3://查看收补，看下级补货上来的 金额就是buhuo
    //             if($aaa!=0){
    //                 $jine = $this->jinec3($new);
    //                 $buhuo = $this->xiajibuhuo($new);
    //                 $yingkui = $this->yingkuic3($new,$zongjine);
    //             }else{
    //                 $jine = array(0);
    //                 $yingkui = array(0);
    //                 $buhuo = array(0);
    //             }
    //             $this->assign('zongbishu',$zongbishu);//总笔数
    //             $this->assign('jine',$jine);//金额
    //             $this->assign('yingkui',$yingkui);//盈亏
    //             $this->assign('bishu',$bishu2);//笔数
    //             $this->assign('buhuo',$buhuo);//补货  
    //         break;
    //         case 4://查看补货，自己补货出去 这里补货就是金额
    //             if($aaa!=0){
    //                 $jine = $this->jinec4($new);
    //                 $yingkui = $this->yingkuic4($new,$zongjine);
    //             }else{
    //                 $yingkui = array(0);
    //                 $jine = array(0);
    //             }
    //             $this->assign('zongbishu',$zongbishu);//总笔数
    //             $this->assign('jine',$jine);//金额
    //             $this->assign('yingkui',$yingkui);//盈亏
    //             $this->assign('bishu',$bishu2);//笔数
    //             $this->assign('buhuo',$buhuo);//补货  
    //         break;
    //         case 5://查看实加外，实货加补货
    //             if($aaa!=0){            
    //                 $jine =  $this->jinec5($new,$upoccupy);
    //                 $yingkui = $this->yingkuic5($new,$upoccupy);
    //             }else{
    //                 $yingkui = array(0);
    //                 $jine = array(0);                    
    //             }
    //             $this->assign('zongbishu',$zongbishu);//总笔数
    //             $this->assign('jine',$jine);//金额
    //             $this->assign('yingkui',$yingkui);//盈亏
    //             $this->assign('bishu',$bishu2);//笔数
    //             $this->assign('buhuo',$buhuo);//补货
    //         break;
    //     }    

    //     $this->assign('res',$res);//全部符合条件的注单
    //     $this->assign('zongjine',$zongjine);//总价

    //     $this->assign('resultSQZRate',$resultSQZRate);//连码赔率
    //     $this->assign('announce',$announce);//广告
    //     $this->assign('arr',$arr);
    //     $this->assign('zongarr',$zongarr);
    //     // mp1($res);

    //     return $this->fetch();
    // }

    //即时注单全不中/多中一(精简ok)(2个bet)
    // public function injectionmiss(){
    //     //全不中 bet=14 ,colums=1
    //     //多中 bet=15, colums=1
    //     //又要分两个写
    //     //半波表示全不中，qima表示多中
    //     $arr = model('orders')->findcount();
    //     foreach ($arr as $key11 => $item11) {
    //         $zongarr += $item11;
    //     }
    //     $new=array();
    //     $announce = model('announce')->findstatus(2);         $resultwbzhong = model("rate")->findswbzhong();//不中 要
    //     $resultsanzhongyi = model("rate")->finds(15);//多中配率 要 
    //     $resquanbuzhongrate = model("rate")->finds(14);//全不中赔率
    //     $resduozhongrate = model("rate")->finds(15);//多中配率
    //     $panlei = $_POST["panlei"];
    //     $check = $_POST["check"];
    //     $update = $_POST["update"];
    //     if($panlei == 0){$panlei = 1;}
    //     $datatime=$this->dangqianqishu();
    //     $uid=$this->id2();//id链

    //     $upoccupy = $this->zhaoupoccupy();
    //     //半波全部情况          
    //     $resbanbo = $this->quanbuzhudan($panlei,14,1,$item,$datatime);
    //     $aaa = 0;        
    //     foreach($resbanbo as $key => $item){
    //         if(!empty($item)){
    //             $aaa += 1;
    //             $zongjinebanbo = $this->zongjine($resbanbo);//半波总金额
    //             $newbanbo = $this->betzhudan($resbanbo);//半波的bets
    //             $abanbo = array_keys($newbanbo);//提取数组下标
    //             $bishubanbo = $this->bishuc0($newbanbo);
    //             $buhuobanbo = $this->buhuoc0($newbanbo);//半波补货
    //             $bishu2banbo = array_combine($abanbo,$bishubanbo);//半波笔数
    //             $zongbishubanbo = $this->zongbishu($bishu2banbo);//半波总笔数
    //         }else{
    //             $aaa += 0;
    //             $bishu2banbo = array(0);//半波笔数
    //             $buhuobanbo = array(0);//半波补货
    //             $zongbishubanbo = array(0); //半波总笔数
    //             $zongjinebanbo = array(0);//半波总金额
    //         }
    //     }        



    //     //七码全部情况        
    //     $resqima = $this->quanbuzhudan($panlei,15,1,$item,$datatime);
    //     $sss = 0;        
    //     foreach($resqima as $ky => $item1){
    //         if(!empty($item1)){
    //             $sss += 1;
    //             $zongjineqima = $this->zongjine($resqima);//七码总金额
    //             $newqima = $this->betzhudan($resqima);//七码的bets
    //             $aqima = array_keys($newqima);//提取数组下标
    //             $bishuqima = $this->bishuc0($newqima);
    //             $buhuoqima = $this->buhuoc0($newqima);//七码补货
    //             $bishu2qima = array_combine($aqima,$bishuqima);//七码笔数
    //             $zongbishuqima = $this->zongbishu($bishu2qima);//七码总笔数
    //         }else{
    //             $sss += 0;
    //             $bishu2qima = array(0);//七码笔数
    //             $buhuoqima = array(0);//七码补货
    //             $zongbishuqima = array(0); //七码总笔数
    //             $zongjineqima = array(0);//七码总金额
    //         }
    //     }

    //     switch($check){
    //         case 0://查看全部

    //             //七码
    //             if($sss!=0){
    //                 $yingkuiqima = $this->yingkuic0($newqima,$zongjineqima);//七码盈亏
    //                 $jineqima = $this->jinec0($newqima);//七码金额
    //             }else{
    //                 $yingkuiqima = array(0);//七码盈亏
    //                 $jineqima = array(0);//七码金额
    //             }

    //             //半波
    //             if($aaa!=0){
    //                 $yingkuibanbo = $this->yingkuic0($newbanbo,$zongjinebanbo);//半波盈亏
    //                 $jinebanbo = $this->jinec0($newbanbo);//半波金额
    //             }else{
    //                 $yingkuibanbo = array(0);//半波盈亏
    //                 $jinebanbo = array(0);//半波金额
    //             }

                
    //             $this->assign('zongbishuqima',$zongbishuqima);//七码总笔数
    //             $this->assign('jineqima',$jineqima);//七码金额
    //             $this->assign('yingkuiqima',$yingkuiqima);//七码盈亏
    //             $this->assign('bishuqima',$bishu2qima);//七码笔数
    //             $this->assign('buhuoqima',$buhuoqima);//七码补货

    //             $this->assign('zongbishubanbo',$zongbishubanbo);//半波总笔数
    //             $this->assign('jinebanbo',$jinebanbo);//半波金额
    //             $this->assign('yingkuibanbo',$yingkuibanbo);//半波盈亏
    //             $this->assign('bishubanbo',$bishu2banbo);//半波笔数
    //             $this->assign('buhuobanbo',$buhuobanbo);//半波补货
    //         break;

    //         case 1://查看实货就是成数减去自己补货出去的

    //             //七码
    //             if($sss!=0){
    //                 $jineqima = $this->jinec1($newqima,$upoccupy);//七码金额
    //                 $yingkuiqima = $this->yingkuic1($newqima,$zongjineqima,$upoccupy);//七码盈亏
    //             }else{
    //                 $jineqima = array(0);//七码金额
    //                 $yingkuiqima = array(0);//七码盈亏
    //             }

    //             //半波
    //             if($aaa!=0){
    //                 $jinebanbo = $this->jinec1($newbanbo,$upoccupy);//半波金额
    //                 $yingkuibanbo = $this->yingkuic1($newbanbo,$zongjinebanbo,$upoccupy);//半波盈亏
    //             }else{
    //                 $jinebanbo = array(0);//半波金额
    //                 $yingkuibanbo = array(0);//半波盈亏
    //             }

    //             $this->assign('zongbishuqima',$zongbishuqima);//七码总笔数
    //             $this->assign('jineqima',$jineqima);//七码金额
    //             $this->assign('yingkuiqima',$yingkuiqima);//七码盈亏
    //             $this->assign('bishuqima',$bishu2qima);//七码笔数
    //             $this->assign('buhuoqima',$buhuoqima);//七码补货

    //             $this->assign('zongbishubanbo',$zongbishubanbo);//半波总笔数
    //             $this->assign('jinebanbo',$jinebanbo);//半波金额
    //             $this->assign('yingkuibanbo',$yingkuibanbo);//半波盈亏
    //             $this->assign('bishubanbo',$bishu2banbo);//半波笔数
    //             $this->assign('buhuobanbo',$buhuobanbo);//半波补货
    //         break;
    //         case 2://查看成数

    //             //七码
    //             if($sss!=0){
    //                 $jineqima = $this->jinec2($newqima,$upoccupy);//七码金额
    //                 $yingkuiqima = $this->yingkuic2($newqima,$zongjineqima,$upoccupy);//七码盈亏
    //             }else{
    //                 $jineqima = array(0);//七码金额
    //                 $yingkuiqima = array(0);//七码盈亏
    //             }

    //             //半波
    //             if($aaa!=0){
    //                 $jinebanbo = $this->jinec2($newbanbo,$upoccupy);//半波金额
    //                 $yingkuibanbo = $this->yingkuic2($newbanbo,$zongjinebanbo,$upoccupy);//半波盈亏
    //             }else{
    //                 $jinebanbo = array(0);//半波金额
    //                 $yingkuibanbo = array(0);//半波盈亏
    //             }

    //             $this->assign('zongbishuqima',$zongbishuqima);//七码总笔数
    //             $this->assign('jineqima',$jineqima);//七码金额
    //             $this->assign('yingkuiqima',$yingkuiqima);//七码盈亏
    //             $this->assign('bishuqima',$bishu2qima);//七码笔数
    //             $this->assign('buhuoqima',$buhuoqima);//七码补货

    //             $this->assign('zongbishubanbo',$zongbishubanbo);//半波总笔数
    //             $this->assign('jinebanbo',$jinebanbo);//半波金额
    //             $this->assign('yingkuibanbo',$yingkuibanbo);//半波盈亏
    //             $this->assign('bishubanbo',$bishu2banbo);//半波笔数
    //             $this->assign('buhuobanbo',$buhuobanbo);//半波补货 
    //         break;
    //         case 3://查看收补，看下级补货上来的 金额就是buhuo

    //             //七码
    //             if($sss!=0){
    //                 $jineqima = $this->jinec3($newqima);//七码金额
    //                 $buhuoqima = $this->xiajibuhuo($newqima);//七码补货
    //                 $yingkuiqima = $this->yingkuic3($newqima,$zongjineqima);//七码盈亏
    //             }else{
    //                 $jineqima = array(0);//七码金额
    //                 $buhuoqima = array(0);//七码补货
    //                 $yingkuiqima = array(0);//七码盈亏
    //             }

    //             //半波
    //             if($aaa!=0){
    //                 $jinebanbo = $this->jinec3($newbanbo);//半波金额
    //                 $buhuobanbo = $this->xiajibuhuo($newbanbo);//半波补货
    //                 $yingkuibanbo = $this->yingkuic3($newbanbo,$zongjinebanbo);//半波盈亏
    //             }else{
    //                 $jinebanbo = array(0);//半波金额
    //                 $buhuobanbo = array(0);//半波补货
    //                 $yingkuibanbo = array(0);//半波盈亏
    //             }

    //             $this->assign('zongbishuqima',$zongbishuqima);//七码总笔数
    //             $this->assign('jineqima',$jineqima);//七码金额
    //             $this->assign('yingkuiqima',$yingkuiqima);//七码盈亏
    //             $this->assign('bishuqima',$bishu2qima);//七码笔数
    //             $this->assign('buhuoqima',$buhuoqima);//七码补货

    //             $this->assign('zongbishubanbo',$zongbishubanbo);//半波总笔数
    //             $this->assign('jinebanbo',$jinebanbo);//半波金额
    //             $this->assign('yingkuibanbo',$yingkuibanbo);//半波盈亏
    //             $this->assign('bishubanbo',$bishu2banbo);//半波笔数
    //             $this->assign('buhuobanbo',$buhuobanbo);//半波补货  
    //         break;
    //         case 4://查看补货，自己补货出去 这里补货就是金额

    //             //七码
    //             if($sss!=0){
    //                 $jineqima = $this->jinec4($newqima);//七码金额
    //                 $yingkuiqima = $this->yingkuic4($newqima,$zongjineqima);//七码盈亏
    //             }else{
    //                 $jineqima = array(0);//七码金额
    //                 $yingkuiqima = array(0);//七码盈亏
    //             }

    //             //半波
    //             if($aaa!=0){
    //                 $jinebanbo = $this->jinec4($newbanbo);//半波金额
    //                 $yingkuibanbo = $this->yingkuic4($newbanbo,$zongjinebanbo);//半波盈亏
    //             }else{
    //                 $jinebanbo = array(0);//半波金额
    //                 $yingkuibanbo = array(0);//半波盈亏
    //             }

    //             $this->assign('zongbishuqima',$zongbishuqima);//七码总笔数
    //             $this->assign('jineqima',$jineqima);//七码金额
    //             $this->assign('yingkuiqima',$yingkuiqima);//七码盈亏
    //             $this->assign('bishuqima',$bishu2qima);//七码笔数
    //             $this->assign('buhuoqima',$buhuoqima);//七码补货

    //             $this->assign('zongbishubanbo',$zongbishubanbo);//半波总笔数
    //             $this->assign('jinebanbo',$jinebanbo);//半波金额
    //             $this->assign('yingkuibanbo',$yingkuibanbo);//半波盈亏
    //             $this->assign('bishubanbo',$bishu2banbo);//半波笔数
    //             $this->assign('buhuobanbo',$buhuobanbo);//半波补货
    //         break;
    //         case 5://查看实加外，实货加补货

    //             //七码
    //             if($sss!=0){
    //                 $jineqima =  $this->jinec5($newqima,$upoccupy);//七码金额
    //                 $yingkuiqima = $this->yingkuic5($newqima,$upoccupy);//七码盈亏
    //             }else{
    //                 $jineqima = array(0);//七码金额
    //                 $yingkuiqima = array(0);//七码盈亏
    //             }

    //             //半波
    //             if($aaa!=0){
    //                 $jinebanbo =  $this->jinec5($newbanbo,$upoccupy);//半波金额
    //                 $yingkuibanbo = $this->yingkuic5($newbanbo,$upoccupy);//半波盈亏
    //             }else{
    //                 $jinebanbo = array(0);//半波金额
    //                 $yingkuibanbo = array(0);//半波盈亏
    //             }

    //             $this->assign('zongbishuqima',$zongbishuqima);//七码总笔数
    //             $this->assign('jineqima',$jineqima);//七码金额
    //             $this->assign('yingkuiqima',$yingkuiqima);//七码盈亏
    //             $this->assign('bishuqima',$bishu2qima);//七码笔数
    //             $this->assign('buhuoqima',$buhuoqima);//七码补货

    //             $this->assign('zongbishubanbo',$zongbishubanbo);//半波总笔数
    //             $this->assign('jinebanbo',$jinebanbo);//半波金额
    //             $this->assign('yingkuibanbo',$yingkuibanbo);//半波盈亏
    //             $this->assign('bishubanbo',$bishu2banbo);//半波笔数
    //             $this->assign('buhuobanbo',$buhuobanbo);//半波补货
    //         break;
    //     }
    //     $this->assign('resbanbo',$resbanbo);//全部符合条件的半波注单
    //     $this->assign('zongjinebanbo',$zongjinebanbo);//半波总价
    //     $this->assign('resqima',$resqima);//全部符合条件的七码注单
    //     $this->assign('zongjineqima',$zongjineqima);//七码总价

    //     $this->assign('resquanbuzhongrate', $resquanbuzhongrate);//全不中赔率
    //     $this->assign('resduozhongrate', $resduozhongrate);//多中赔率
    //     $this->assign('resultwbzhong',$resultwbzhong);
    //     $this->assign('resultsanzhongyi',$resultsanzhongyi);
    //     $this->assign('datatime',$datatime);//期数
    //     $this->assign('announce',$announce);//广告
    //     $this->assign('arr',$arr);//上面的笔数
    //     $this->assign('zongarr',$zongarr);//上面的总笔数
    //     // mp1($resbanbo);
    //     // mp1($resqima);
    //     // mp1($zongbishuqima);
    //     // mp1($jineqima);
    //     // mp1($jinebanbo);
    //     return $this->fetch();
    // }

    public function injectionqise($andicap=1,$type=1,$upd=0){
        // type=1 全部 2实货  3是成数 4是收补 5是补货 6实+补
        // upd 1 2 3 4 更新
        // andicap 盘口
        $timeinterval = $this->timeinterval();
        if($timeinterval==1){
            $opentime = 1;
        }else{        
            $opentime = $timeinterval['opentime'];
        }
        $rate13 = array();$rate9=array();
        // mp1($opentime);
        $datatime = $this->dangqianqishu();
        $announce = model('announce')->findstatus(2);
        $ids = $this->id();
        $rate13 = model('rate')->where('bet',13)->select();
        $rate9 = model('rate')->where('bet',9)->select();
        if($datatime==0){
           $datatime = 0;             
        }else{
            foreach ($ids['u7'] as $key => $va) {
                //拿当期所有13和9的注单注单
                    $res13 = model('ordered')->finrede(1,13,$va,$datatime,session('adminid'));
                    $res9 = model('ordered')->finrede(1,9,$va,$datatime,session('adminid'));
            }
            //拿赔率+盘差
            
            foreach ($rate13 as $k13 => $v13) {
                $data = getpancha($andicap,$v13['bet'],$v13['colums'],$v13["bets"]);
                $data = json_decode($data,true);
                model('pancha')->findandicap($id,$n);
            }
        }
        if(empty($rate13))return $rate13 = [];
        if(empty($rate9))return $rate9 = [];
        $r13 = $this->ordershow($res13);
        if(empty($r13)){
           $res13=$r13;
        }else{
             $res13 = json_decode($r13,true);
        }
        $r9 = $this->ordershow($res9);
        if(empty($r9)){
           $res9=$r9; 
        }else{
             $res9 = json_decode($r9,true);
        }
        // mp($restemp);
        $arr = model('orders')->findcount();
        foreach ($arr as $key11 => $item11) {
            $zongarr += $item11;
        }
        $opentime = 0;
        $announce = model('announce')->findstatus(2);
        // mp1($res13);
        // mp1($res9);
        $this->assign("andicap",$andicap);
        $this->assign('upd',$upd);
        $this->assign('res13',$res13); 
        $this->assign('res9',$res9); 
        $this->assign('resultyixiao',$rate13); 
        $this->assign('resultzhengxiao',$rate9);
        $this->assign('datatime',$datatime);//期数
        $this->assign('announce',$announce);//广告
        $this->assign('arr',$arr);//上面的笔数
        $this->assign('zongarr',$zongarr);//上面的总笔数 
        $this->assign('opentime',$opentime);
        return $this->fetch();
    }

    public function injectionlianma($andicap=1,$type=1,$upd=0){
        // type=1 全部 2实货  3是成数 4是收补 5是补货 6实+补
        // upd 1 2 3 4 更新
        // andicap 盘口
        $timeinterval = $this->timeinterval();
        if($timeinterval==1){
            $opentime = 1;
        }else{        
            $opentime = $timeinterval['opentime'];
        }
        $rate7 = array();
        $datatime = $this->dangqianqishu();
        $announce = model('announce')->findstatus(2);
        $ids = $this->id();
        if($datatime==0){
           $datatime = 0;             
        }else{
            foreach ($ids['u7'] as $key => $va) {
                //拿当期所有7
                $res7 = model('ordered')->finrede(1,7,$va,$datatime,session('adminid'));
            }
            foreach ($res7 as $k => $v1) {
                $r7 = model('rate')->where(['bet'=>$v1['bet'],'colums'=>$v1['colums'],'bets'=>$v1['bets']])->find();
                $res7[$k]['ts'] = model('occupy')->tsinser($v1['andicap'],$v1['bet'],$v1['colums'],$v1['bets'],$v1['user_id']);
                $use7 = model('user')->where('id',$v1['user_id'])->find();
                // 账号名称
                $res7[$k]['uname'] = $use7['name'];
                // 账号
                $res7[$k]['username'] = $use7['username'];
                // 下注内容
                $res7[$k]['content'] = inserpankous($v1['bet'],$v1['colums'],$v1['bets'],$r7['name']);
                // 号码
                $res7[$k]['number'] = $k+1;
                // 预计盈亏
                $res7[$k]['money'] = $v1['price']-$v1['price']*$v1['rate'];
            }
        }
        $opentime = 0;
        $announce = model('announce')->findstatus(2);
        $arr = model('orders')->findcount();
        foreach ($arr as $key11 => $item11) {
            $zongarr += $item11;
        }
        $this->assign("andicap",$andicap);
        $this->assign('upd',$upd);
        $this->assign('res7',$res7); 
        $this->assign('datatime',$datatime);//期数
        $this->assign('announce',$announce);//广告
        $this->assign('arr',$arr);//上面的笔数
        $this->assign('zongarr',$zongarr);//上面的总笔数 
        $this->assign('opentime',$opentime);
        // mp1($res7);
        return $this->fetch();
            // [id] => 239  单号
            // [user_id] => 2
            // [times] => 1522648751 时间
            // [status] => 1
            // [methods] => 1
            // [datatime] => 203
            // [price] => 100  下注金额
            // [jiesuan] => 1
            // [order_id] => 132
            // [andicap] => 1  盘类
            // [bet] => 7
            // [bets] => 1,2,3
            // [colums] => 1
            // [uid] => 2
            // [rate] => 720 赔率
            // [zhongjiang] => 0
            // [bh] => 0
            // [sb] => 0
            // [ts] => 15.05 退水
            // [uname] => 测试  名称
            // [username] => 123   账号
            // [content] => 连码[三全中]1,2,3    下注内容
            // [number] => 1    No
            // [money] => -71900     可赢金额
    }

    public function injectiondxx($andicap=1,$type=1,$upd=0){
    // type=1 全部 2实货  3是成数 4是收补 5是补货 6实+补
    // upd 1 2 3 4 更新
    // andicap 盘口
    $timeinterval = $this->timeinterval();
    if($timeinterval==1){
        $opentime = 1;
    }else{        
        $opentime = $timeinterval['opentime'];
    }
    $rate10 = array();
    $rate12 = array();
    $rate5 = array();
    $rate11 = array();
    $datatime = $this->dangqianqishu();
    $announce = model('announce')->findstatus(2);
    $ids = $this->id();
    if($datatime==0){
       $datatime = 0;             
    }else{
        foreach ($ids['u7'] as $key => $va) {
            //拿当期所有7
            $res10 = model('ordered')->finrede(1,10,$va,$datatime,session('adminid'));
            $res12 = model('ordered')->finrede(1,12,$va,$datatime,session('adminid'));
            $res11 = model('ordered')->finrede(1,11,$va,$datatime,session('adminid'));
            $res5 = model('ordered')->finrede(1,5,$va,$datatime,session('adminid'));
        }
        $res10 = $this->shuzucaozuo($res10);
        $res12 = $this->shuzucaozuo($res12);
        $res11 = $this->shuzucaozuo($res11);
        $res5 = $this->shuzucaozuo($res5);
        $res10 = json_decode($res10,true);
        $res12 = json_decode($res12,true);
        $res11 = json_decode($res11,true);
        $res5 = json_decode($res5,true);
    }
    $opentime = 0;
    $announce = model('announce')->findstatus(2);
    $arr = model('orders')->findcount();
    foreach ($arr as $key11 => $item11) {
        $zongarr += $item11;
    }
    $this->assign("andicap",$andicap);
    $this->assign('upd',$upd);
    $this->assign('res10',$res10);
    $this->assign('res12',$res12);
    $this->assign('res11',$res11);
    $this->assign('res5',$res5); 
    $this->assign('datatime',$datatime);//期数
    $this->assign('announce',$announce);//广告
    $this->assign('arr',$arr);//上面的笔数
    $this->assign('zongarr',$zongarr);//上面的总笔数 
    $this->assign('opentime',$opentime);

    return $this->fetch();
    }

    public function injectionmiss($andicap=1,$type=1,$upd=0){
    // type=1 全部 2实货  3是成数 4是收补 5是补货 6实+补
    // upd 1 2 3 4 更新
    // andicap 盘口
    $timeinterval = $this->timeinterval();
    if($timeinterval==1){
        $opentime = 1;
    }else{        
        $opentime = $timeinterval['opentime'];
    }
    $rate14 = array();
    $rate15 = array();
    $datatime = $this->dangqianqishu();
    $announce = model('announce')->findstatus(2);
    $ids = $this->id();
    if($datatime==0){
       $datatime = 0;             
    }else{
        foreach ($ids['u7'] as $key => $va) {
            //拿当期所有7
            $res14 = model('ordered')->finrede(1,14,$va,$datatime,session('adminid'));
            $res15 = model('ordered')->finrede(1,15,$va,$datatime,session('adminid'));
        }
        $res14 = $this->shuzucaozuo($res14);
        $res15 = $this->shuzucaozuo($res15);
        $res14 = json_decode($res14,true);
        $res15 = json_decode($res15,true);
    }
    $opentime = 0;
    $announce = model('announce')->findstatus(2);

    $arr = model('orders')->findcount();
    // mp($arr);

    foreach ($arr as $key11 => $item11) {
        $zongarr += $item11;
    }

    $this->assign("andicap",$andicap);
    $this->assign('upd',$upd);
    $this->assign('res14',$res14);
    $this->assign('res15',$res15);
    $this->assign('datatime',$datatime);//期数
    $this->assign('announce',$announce);//广告
    $this->assign('arr',$arr);//上面的笔数
    $this->assign('zongarr',$zongarr);//上面的总笔数 
    $this->assign('opentime',$opentime);
    return $this->fetch();
}
    public function ordershow($arr){
        if(empty($arr))return $data=array();
        foreach($arr as $k => $val){
            if(!isset($tmp)){
                $tmp[] = array( 'bet'=>$val['bet'],'colums'=>$val['colums'], 'bets'=>$val['bets'] ,'price'=>$val['price'],"number"=>1 );
            }else{
                $tmp[] = array( 'bet'=>$val['bet'],'colums'=>$val['colums'], 'bets'=>$val['bets'] ,'price'=>$val['price'],"number"=>1 );
            }
        }
        // mp($tmp);
        $restemp = [];
        foreach ($tmp as $item) {
            $rates[$item['bet']][$item['colums']][$item['bets']]['price'] += $item['price'];
            $rates[$item['bet']][$item['colums']][$item['bets']]['number'] += $item['number'];
        }
        // mp($rates);
        foreach ($rates as $k1 => $v1) {
            foreach ($v1 as $k2 => $v2) {
                foreach ($v2 as $k3 => $v3) {
                    $restemp[] = ['bet' =>$k1,'colums'=>$k2,'bets'=>$k3,'price'=>$v3['price'],'number'=>$v3['number']];
                }
            }
        }
        $data = json_encode($restemp);
        return $data;
    }

    public function shuzucaozuo($res){
            foreach ($res as $k => $v1) {
                $r = model('rate')->where(['bet'=>$v1['bet'],'colums'=>$v1['colums'],'bets'=>$v1['bets']])->find();
                $res[$k]['ts'] = model('occupy')->tsinser($v1['andicap'],$v1['bet'],$v1['colums'],$v1['bets'],$v1['user_id']);
                $use7 = model('user')->where('id',$v1['user_id'])->find();
                // 账号名称
                $res[$k]['uname'] = $use7['name'];
                // 账号
                $res[$k]['username'] = $use7['username'];
                // 下注内容
                $res[$k]['content'] = inserpankous($v1['bet'],$v1['colums'],$v1['bets'],$r7['name']);
                // 号码
                $res[$k]['number'] = $k+1;
                // 预计盈亏
                $res[$k]['money'] = $v1['price']-$v1['price']*$v1['rate'];
            }
            $res = json_encode($res);
            return $res;
    }

    // //即时注单正总一肖正特尾数七色波(精简ok)(3个bet)
    // public function injectionqise(){
    //     //一肖 bet=13(七码)
    //     //不中 bet=14(半波)
    //     //正肖 bet=9 (正码过关)
    //     //又要分两个写

    //     $arr = model('orders')->findcount();
    //     foreach ($arr as $key11 => $item11) {
    //         $zongarr += $item11;
    //     }
    //     $new=array();
    //     $announce = model('announce')->findstatus(2);
    //     $reszhengxiaorate = model("rate")->finds(9); //正肖赔率
    //     $resyixiaorate = model("rate")->finds(13); //一肖赔率
    //     $resbuzhongrate = model("rate")->finds(14); //不中赔率
    //     $resultzhengxiao = model("rate")->finds(9); //正肖赔率
    //     $resultyixiao = model("rate")->finds(13); //一肖赔率
    //     $panlei = $_POST["panlei"];
    //     $check = $_POST["check"];
    //     $update = $_POST["update"];
    //     if($panlei == 0){$panlei = 1;}
    //     $datatime=$this->dangqianqishu();
    //     $uid=$this->id2();//id链

    //     $upoccupy = $this->zhaoupoccupy();
    //     //半波全部情况          
    //     $resbanbo = $this->quanbuzhudan($panlei,14,1,$item,$datatime);
    //     $aaa = 0;        
    //     foreach($resbanbo as $key => $item){
    //         if(!empty($item)){
    //             $aaa += 1;
    //             $zongjinebanbo = $this->zongjine($resbanbo);//半波总金额
    //             $newbanbo = $this->betzhudan($resbanbo);//半波的bets
    //             $abanbo = array_keys($newbanbo);//提取数组下标
    //             $bishubanbo = $this->bishuc0($newbanbo);
    //             $buhuobanbo = $this->buhuoc0($newbanbo);//半波补货
    //             $bishu2banbo = array_combine($abanbo,$bishubanbo);//半波笔数
    //             $zongbishubanbo = $this->zongbishu($bishu2banbo);//半波总笔数
    //         }else{
    //             $aaa += 0;
    //             $bishu2banbo = array(0);//半波笔数
    //             $buhuobanbo = array(0);//半波补货
    //             $zongbishubanbo = array(0); //半波总笔数
    //             $zongjinebanbo = array(0);//半波总金额
    //         }
    //     }        

    //     //七码全部情况        
    //     $resqima = $this->quanbuzhudan($panlei,13,1,$item,$datatime);
    //     $sss = 0;        
    //     foreach($resqima as $ky => $item1){
    //         if(!empty($item1)){
    //             $sss += 1;
    //             $zongjineqima = $this->zongjine($resqima);//七码总金额
    //             $newqima = $this->betzhudan($resqima);//七码的bets
    //             $aqima = array_keys($newqima);//提取数组下标
    //             $bishuqima = $this->bishuc0($newqima);
    //             $buhuoqima = $this->buhuoc0($newqima);//七码补货
    //             $bishu2qima = array_combine($aqima,$bishuqima);//七码笔数
    //             $zongbishuqima = $this->zongbishu($bishu2qima);//七码总笔数
    //         }else{
    //             $sss += 0;
    //             $bishu2qima = array(0);//七码笔数
    //             $buhuoqima = array(0);//七码补货
    //             $zongbishuqima = array(0); //七码总笔数
    //             $zongjineqima = array(0);//七码总金额
    //         }
    //     }

    //     //正码过关
    //     $reszmgg = $this->quanbuzhudan($panlei,9,1,$item,$datatime);
    //     $zzz = 0;        
    //     foreach($reszmgg as $ky => $item1){
    //         if(!empty($item1)){
    //             $zzz += 1;
    //             $zongjinezmgg = $this->zongjine($reszmgg);//正码过关总金额
    //             $newzmgg = $this->betzhudan($reszmgg);//正码过关的bets
    //             $azmgg = array_keys($newzmgg);//提取数组下标
    //             $bishuzmgg = $this->bishuc0($newzmgg);
    //             $buhuozmgg = $this->buhuoc0($newzmgg);//正码过关补货
    //             $bishu2zmgg = array_combine($azmgg,$bishuzmgg);//正码过关笔数
    //             $zongbishuzmgg = $this->zongbishu($bishu2zmgg);//正码过关总笔数
    //         }else{
    //             $zzz += 0;
    //             $bishu2zmgg = array(0);//正码过关笔数
    //             $buhuozmgg = array(0);//正码过关补货
    //             $zongbishuzmgg = array(0); //正码过关总笔数
    //             $zongjinezmgg = array(0);//正码过关总金额
    //         }
    //     }

    //     switch($check){
    //         case 0://查看全部

    //             //七码
    //             if($sss!=0){
    //                 $yingkuiqima = $this->yingkuic0($newqima,$zongjineqima);//七码盈亏
    //                 $jineqima = $this->jinec0($newqima);//七码金额
    //             }else{
    //                 $yingkuiqima = array(0);//七码盈亏
    //                 $jineqima = array(0);//七码金额
    //             }

    //             //半波
    //             if($aaa!=0){
    //                 $yingkuibanbo = $this->yingkuic0($newbanbo,$zongjinebanbo);//半波盈亏
    //                 $jinebanbo = $this->jinec0($newbanbo);//半波金额
    //             }else{
    //                 $yingkuibanbo = array(0);//半波盈亏
    //                 $jinebanbo = array(0);//半波金额
    //             }

    //             //正码过关
    //             if($zzz!=0){
    //                 $yingkuizmgg = $this->yingkuic0($newzmgg,$zongjinezmgg);//半波盈亏
    //                 $jinezmgg = $this->jinec0($newzmgg);//半波金额
    //             }else{
    //                 $yingkuizmgg = array(0);//半波盈亏
    //                 $jinezmgg = array(0);//半波金额
    //             }
                
    //             $this->assign('zongbishuqima',$zongbishuqima);//七码总笔数
    //             $this->assign('jineqima',$jineqima);//七码金额
    //             $this->assign('yingkuiqima',$yingkuiqima);//七码盈亏
    //             $this->assign('bishuqima',$bishu2qima);//七码笔数
    //             $this->assign('buhuoqima',$buhuoqima);//七码补货

    //             $this->assign('zongbishuzmgg',$zongbishuzmgg);//正码过关总笔数
    //             $this->assign('jinezmgg',$jinezmgg);//正码过关金额
    //             $this->assign('yingkuizmgg',$yingkuizmgg);//正码过关盈亏
    //             $this->assign('bishuzmgg',$bishu2zmgg);//正码过关笔数
    //             $this->assign('buhuozmgg',$buhuozmgg);//正码过关补货

    //             $this->assign('zongbishubanbo',$zongbishubanbo);//半波总笔数
    //             $this->assign('jinebanbo',$jinebanbo);//半波金额
    //             $this->assign('yingkuibanbo',$yingkuibanbo);//半波盈亏
    //             $this->assign('bishubanbo',$bishu2banbo);//半波笔数
    //             $this->assign('buhuobanbo',$buhuobanbo);//半波补货
    //         break;

    //         case 1://查看实货就是成数减去自己补货出去的

    //             //七码
    //             if($sss!=0){
    //                 $jineqima = $this->jinec1($newqima,$upoccupy);//七码金额
    //                 $yingkuiqima = $this->yingkuic1($newqima,$zongjineqima,$upoccupy);//七码盈亏
    //             }else{
    //                 $jineqima = array(0);//七码金额
    //                 $yingkuiqima = array(0);//七码盈亏
    //             }

    //             //半波
    //             if($aaa!=0){
    //                 $jinebanbo = $this->jinec1($newbanbo,$upoccupy);//半波金额
    //                 $yingkuibanbo = $this->yingkuic1($newbanbo,$zongjinebanbo,$upoccupy);//半波盈亏
    //             }else{
    //                 $jinebanbo = array(0);//半波金额
    //                 $yingkuibanbo = array(0);//半波盈亏
    //             }

    //             //正码过关
    //             if($zzz!=0){
    //                 $jinezmgg = $this->jinec1($newzmgg,$upoccupy);//正码过关金额
    //                 $yingkuizmgg = $this->yingkuic1($newzmgg,$zongjinezmgg,$upoccupy);//正码过关盈亏
    //             }else{
    //                 $jinezmgg = array(0);//正码过关金额
    //                 $yingkuizmgg = array(0);//正码过关盈亏
    //             }

    //             $this->assign('zongbishuqima',$zongbishuqima);//七码总笔数
    //             $this->assign('jineqima',$jineqima);//七码金额
    //             $this->assign('yingkuiqima',$yingkuiqima);//七码盈亏
    //             $this->assign('bishuqima',$bishu2qima);//七码笔数
    //             $this->assign('buhuoqima',$buhuoqima);//七码补货

    //             $this->assign('zongbishuzmgg',$zongbishuzmgg);//正码过关总笔数
    //             $this->assign('jinezmgg',$jinezmgg);//正码过关金额
    //             $this->assign('yingkuizmgg',$yingkuizmgg);//正码过关盈亏
    //             $this->assign('bishuzmgg',$bishu2zmgg);//正码过关笔数
    //             $this->assign('buhuozmgg',$buhuozmgg);//正码过关补货

    //             $this->assign('zongbishubanbo',$zongbishubanbo);//半波总笔数
    //             $this->assign('jinebanbo',$jinebanbo);//半波金额
    //             $this->assign('yingkuibanbo',$yingkuibanbo);//半波盈亏
    //             $this->assign('bishubanbo',$bishu2banbo);//半波笔数
    //             $this->assign('buhuobanbo',$buhuobanbo);//半波补货
    //         break;
    //         case 2://查看成数

    //             //七码
    //             if($sss!=0){
    //                 $jineqima = $this->jinec2($newqima,$upoccupy);//七码金额
    //                 $yingkuiqima = $this->yingkuic2($newqima,$zongjineqima,$upoccupy);//七码盈亏
    //             }else{
    //                 $jineqima = array(0);//七码金额
    //                 $yingkuiqima = array(0);//七码盈亏
    //             }

    //             //半波
    //             if($aaa!=0){
    //                 $jinebanbo = $this->jinec2($newbanbo,$upoccupy);//半波金额
    //                 $yingkuibanbo = $this->yingkuic2($newbanbo,$zongjinebanbo,$upoccupy);//半波盈亏
    //             }else{
    //                 $jinebanbo = array(0);//半波金额
    //                 $yingkuibanbo = array(0);//半波盈亏
    //             }

    //             //正码过关
    //             if($zzz!=0){
    //                 $jinezmgg = $this->jinec2($newzmgg,$upoccupy);//正码过关金额
    //                 $yingkuizmgg = $this->yingkuic2($newzmgg,$zongjinezmgg,$upoccupy);//正码过关盈亏
    //             }else{
    //                 $jinezmgg = array(0);//正码过关金额
    //                 $yingkuizmgg = array(0);//正码过关盈亏
    //             }

    //             $this->assign('zongbishuqima',$zongbishuqima);//七码总笔数
    //             $this->assign('jineqima',$jineqima);//七码金额
    //             $this->assign('yingkuiqima',$yingkuiqima);//七码盈亏
    //             $this->assign('bishuqima',$bishu2qima);//七码笔数
    //             $this->assign('buhuoqima',$buhuoqima);//七码补货

    //             $this->assign('zongbishuzmgg',$zongbishuzmgg);//正码过关总笔数
    //             $this->assign('jinezmgg',$jinezmgg);//正码过关金额
    //             $this->assign('yingkuizmgg',$yingkuizmgg);//正码过关盈亏
    //             $this->assign('bishuzmgg',$bishu2zmgg);//正码过关笔数
    //             $this->assign('buhuozmgg',$buhuozmgg);//正码过关补货

    //             $this->assign('zongbishubanbo',$zongbishubanbo);//半波总笔数
    //             $this->assign('jinebanbo',$jinebanbo);//半波金额
    //             $this->assign('yingkuibanbo',$yingkuibanbo);//半波盈亏
    //             $this->assign('bishubanbo',$bishu2banbo);//半波笔数
    //             $this->assign('buhuobanbo',$buhuobanbo);//半波补货
    //         break;
    //         case 3://查看收补，看下级补货上来的 金额就是buhuo

    //             //七码
    //             if($sss!=0){
    //                 $jineqima = $this->jinec3($newqima);//七码金额
    //                 $buhuoqima = $this->xiajibuhuo($newqima);//七码补货
    //                 $yingkuiqima = $this->yingkuic3($newqima,$zongjineqima);//七码盈亏
    //             }else{
    //                 $jineqima = array(0);//七码金额
    //                 $buhuoqima = array(0);//七码补货
    //                 $yingkuiqima = array(0);//七码盈亏
    //             }

    //             //半波
    //             if($aaa!=0){
    //                 $jinebanbo = $this->jinec3($newbanbo);//半波金额
    //                 $buhuobanbo = $this->xiajibuhuo($newbanbo);//半波补货
    //                 $yingkuibanbo = $this->yingkuic3($newbanbo,$zongjinebanbo);//半波盈亏
    //             }else{
    //                 $jinebanbo = array(0);//半波金额
    //                 $buhuobanbo = array(0);//半波补货
    //                 $yingkuibanbo = array(0);//半波盈亏
    //             }

    //             //正码过关
    //             if($zzz!=0){
    //                 $jinezmgg = $this->jinec3($newzmgg);//正码过关金额
    //                 $buhuozmgg = $this->xiajibuhuo($newzmgg);//正码过关补货
    //                 $yingkuizmgg = $this->yingkuic3($newzmgg,$zongjinezmgg);//正码过关盈亏
    //             }else{
    //                 $jinezmgg = array(0);//正码过关金额
    //                 $buhuozmgg = array(0);//正码过关补货
    //                 $yingkuizmgg = array(0);//正码过关盈亏
    //             }                

    //             $this->assign('zongbishuqima',$zongbishuqima);//七码总笔数
    //             $this->assign('jineqima',$jineqima);//七码金额
    //             $this->assign('yingkuiqima',$yingkuiqima);//七码盈亏
    //             $this->assign('bishuqima',$bishu2qima);//七码笔数
    //             $this->assign('buhuoqima',$buhuoqima);//七码补货

    //             $this->assign('zongbishuzmgg',$zongbishuzmgg);//正码过关总笔数
    //             $this->assign('jinezmgg',$jinezmgg);//正码过关金额
    //             $this->assign('yingkuizmgg',$yingkuizmgg);//正码过关盈亏
    //             $this->assign('bishuzmgg',$bishu2zmgg);//正码过关笔数
    //             $this->assign('buhuozmgg',$buhuozmgg);//正码过关补货

    //             $this->assign('zongbishubanbo',$zongbishubanbo);//半波总笔数
    //             $this->assign('jinebanbo',$jinebanbo);//半波金额
    //             $this->assign('yingkuibanbo',$yingkuibanbo);//半波盈亏
    //             $this->assign('bishubanbo',$bishu2banbo);//半波笔数
    //             $this->assign('buhuobanbo',$buhuobanbo);//半波补货  
    //         break;
    //         case 4://查看补货，自己补货出去 这里补货就是金额

    //             //七码
    //             if($sss!=0){
    //                 $jineqima = $this->jinec4($newqima);//七码金额
    //                 $yingkuiqima = $this->yingkuic4($newqima,$zongjineqima);//七码盈亏
    //             }else{
    //                 $jineqima = array(0);//七码金额
    //                 $yingkuiqima = array(0);//七码盈亏
    //             }

    //             //半波
    //             if($aaa!=0){
    //                 $jinebanbo = $this->jinec4($newbanbo);//半波金额
    //                 $yingkuibanbo = $this->yingkuic4($newbanbo,$zongjinebanbo);//半波盈亏
    //             }else{
    //                 $jinebanbo = array(0);//半波金额
    //                 $yingkuibanbo = array(0);//半波盈亏
    //             }

    //             //正码过关
    //             if($zzz!=0){
    //                 $jinezmgg = $this->jinec4($newzmgg);//正码过关金额
    //                 $yingkuizmgg = $this->yingkuic4($newzmgg,$zongjinezmgg);//正码过关盈亏
    //             }else{
    //                 $jinezmgg = array(0);//正码过关金额
    //                 $yingkuizmgg = array(0);//正码过关盈亏
    //             }

    //             $this->assign('zongbishuqima',$zongbishuqima);//七码总笔数
    //             $this->assign('jineqima',$jineqima);//七码金额
    //             $this->assign('yingkuiqima',$yingkuiqima);//七码盈亏
    //             $this->assign('bishuqima',$bishu2qima);//七码笔数
    //             $this->assign('buhuoqima',$buhuoqima);//七码补货

    //             $this->assign('zongbishuzmgg',$zongbishuzmgg);//正码过关总笔数
    //             $this->assign('jinezmgg',$jinezmgg);//正码过关金额
    //             $this->assign('yingkuizmgg',$yingkuizmgg);//正码过关盈亏
    //             $this->assign('bishuzmgg',$bishu2zmgg);//正码过关笔数
    //             $this->assign('buhuozmgg',$buhuozmgg);//正码过关补货

    //             $this->assign('zongbishubanbo',$zongbishubanbo);//半波总笔数
    //             $this->assign('jinebanbo',$jinebanbo);//半波金额
    //             $this->assign('yingkuibanbo',$yingkuibanbo);//半波盈亏
    //             $this->assign('bishubanbo',$bishu2banbo);//半波笔数
    //             $this->assign('buhuobanbo',$buhuobanbo);//半波补货
    //         break;
    //         case 5://查看实加外，实货加补货

    //             //七码
    //             if($sss!=0){
    //                 $jineqima =  $this->jinec5($newqima,$upoccupy);//七码金额
    //                 $yingkuiqima = $this->yingkuic5($newqima,$upoccupy);//七码盈亏
    //             }else{
    //                 $jineqima = array(0);//七码金额
    //                 $yingkuiqima = array(0);//七码盈亏
    //             }

    //             //半波
    //             if($aaa!=0){
    //                 $jinebanbo =  $this->jinec5($newbanbo,$upoccupy);//半波金额
    //                 $yingkuibanbo = $this->yingkuic5($newbanbo,$upoccupy);//半波盈亏
    //             }else{
    //                 $jinebanbo = array(0);//半波金额
    //                 $yingkuibanbo = array(0);//半波盈亏
    //             }

    //             //正码过关
    //             if($zzz!=0){
    //                 $jinezmgg =  $this->jinec5($newzmgg,$upoccupy);//正码过关金额
    //                 $yingkuizmgg = $this->yingkuic5($newzmgg,$upoccupy);//正码过关盈亏
    //             }else{
    //                 $jinezmgg = array(0);//正码过关金额
    //                 $yingkuizmgg = array(0);//正码过关盈亏
    //             }

    //             $this->assign('zongbishuqima',$zongbishuqima);//七码总笔数
    //             $this->assign('jineqima',$jineqima);//七码金额
    //             $this->assign('yingkuiqima',$yingkuiqima);//七码盈亏
    //             $this->assign('bishuqima',$bishu2qima);//七码笔数
    //             $this->assign('buhuoqima',$buhuoqima);//七码补货

    //             $this->assign('zongbishuzmgg',$zongbishuzmgg);//正码过关总笔数
    //             $this->assign('jinezmgg',$jinezmgg);//正码过关金额
    //             $this->assign('yingkuizmgg',$yingkuizmgg);//正码过关盈亏
    //             $this->assign('bishuzmgg',$bishu2zmgg);//正码过关笔数
    //             $this->assign('buhuozmgg',$buhuozmgg);//正码过关补货

    //             $this->assign('zongbishubanbo',$zongbishubanbo);//半波总笔数
    //             $this->assign('jinebanbo',$jinebanbo);//半波金额
    //             $this->assign('yingkuibanbo',$yingkuibanbo);//半波盈亏
    //             $this->assign('bishubanbo',$bishu2banbo);//半波笔数
    //             $this->assign('buhuobanbo',$buhuobanbo);//半波补货
    //         break;
    //     }
    //     $datatime = $this->dangqianqishu();
    //     $this->assign('opentime',$opentime);
    //     $this->assign('resbanbo',$resbanbo);//全部符合条件的半波注单
    //     $this->assign('zongjinebanbo',$zongjinebanbo);//半波总价
    //     $this->assign('resqima',$resqima);//全部符合条件的七码注单
    //     $this->assign('zongjineqima',$zongjineqima);//七码总价
    //     $this->assign('reszmgg',$reszmgg);//全部符合条件的正码过关注单
    //     $this->assign('zongjinezmgg',$zongjinezmgg);//正码过关总价

    //     $this->assign('reszhengxiaorate', $reszhengxiaorate);//正肖赔率
    //     $this->assign('resyixiaorate', $resyixiaorate);//一肖赔率
    //     $this->assign('resbuzhongrate',$resbuzhongrate);//不中赔率
    //     $this->assign('resultyixiao',$resultyixiao);
    //     $this->assign('resultzhengxiao',$resultzhengxiao);
    //     $this->assign('resultZTDXXduoxiaoRate', $resultZTDXXduoxiaoRate);
    //     $this->assign('resweishulianRate', $resweishulianRate);
    //     $this->assign('res10', $res10);
    //     $this->assign('resultZMGGRate',$resultZMGGRate);
    //     $this->assign('datatime',$datatime);//期数
    //     $this->assign('announce',$announce);//广告
    //     $this->assign('arr',$arr);//上面的笔数
    //     $this->assign('zongarr',$zongarr);//上面的总笔数
    //     // mp1($resbanbo);
    //     mp1($resqima);
    //     mp1($reszmgg);
    //     return $this->fetch();
    // }

    public function buhuo(){
        $announce = model('announce')->findstatus(2);
        $this->assign('announce',$announce);
        return $this->fetch();
    }
     //判断并提取符合条件的时间戳bobo
    public function timeinterval(){
        $stime = time();
        // $stime = 1522339200;
        $res=model('openplate')->findtime1();
        // mp($res);
        foreach($res as $key => $item){
            if($stime>=$item['opentime'] && $stime<=$item['tclosetime']){
                $result = 1;//在开盘中
                return $result;
                exit();
            }
            $opentime[$item['datetime']] = $item['opentime'];
            $tclosetime[$item['datetime']] = $item['tclosetime'];
            $zclosetime[$item['datetime']] = $item['zclosetime'];
        }

        foreach($opentime as $key1 => $item1){
            if($stime < $item1){
                $opentime2[] = $item1;
                $a = array_search(min($opentime2), $opentime2);
                $result['opentime'] = $opentime2[$a]; 
            }
        }

        foreach($tclosetime as $key2 => $item2){
            if($stime < $item2){
                $tclosetime2[] = $item2;
                $a = array_search(min($tclosetime2), $tclosetime2);
                $result['tclosetime'] = $tclosetime2[$a]; 
            }
        }

        foreach($zclosetime as $key2 => $item2){
            if($stime < $item2){
                $zclosetime2[] = $item2;
                $a = array_search(min($zclosetime2), $zclosetime2);
                $result['zclosetime'] = $tclosetime2[$a]; 
            }
        }
                        
        return $result;
    }
}
